6

I'm trying to show an image on MBProgressHUD by using this code

MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark"]] autorelease];
HUD.mode = MBProgressHUDModeCustomView;
HUD.labelText = @"تم إرسال وزنك بنجاح";

[HUD show:YES];
[HUD hide:YES afterDelay:1.5];

but this is what i get

enter image description here

what is the problem ?

OXXY
  • 1,047
  • 2
  • 18
  • 43
  • 1
    I tried your code and it is working for me. Its just that I used self.view as superview of HUD. make sure you downloaded the right image. It should be 37 x 37 pixels – Puneet Sharma Jul 21 '13 at 09:08
  • You just need to put .png in the [UIImage ImageNamed], it doesnt know what the file extension is at the moment so it will just throw nothing... T – Taylor Abernethy Newman Aug 06 '13 at 04:37
  • [UIImage imageNamed:] does not require the file extension when being used with a PNG. The file extension is required, however, for other file types. For what it's worth, imageNamed will also auto-cache and will determine the correct file for the device screen scale/DPI if the file is named using Apple's graphics naming conventions, such as "myfile@2x" vs. "myfile". In both cases, "png" will be assumed even if it isn't specified for "imageNamed:". – Woodster Mar 26 '14 at 00:55

4 Answers4

2

I tried your code and it is working for me.

In MBProgressHud.h file, in comments it is mentioned that

/**
 * The UIView (i.g., a UIIMageView) to be shown when the HUD is in MBProgressHUDModeCustomView.
 * For best results use a 37 by 37 pixel view (so the bounds match the build in indicator bounds). 
 */

So perhaps the image you used is missing or is noyt included. Please check that.

Puneet Sharma
  • 9,369
  • 1
  • 27
  • 33
0

You must include the images from this link in your xcode project, seems you didn't do so.

MuhammadBassio
  • 1,590
  • 10
  • 13
0

That's because you don't have the image named "37x-Checkmark" in your project. Just add the 37x-Checkmark.png image file in your project.

x4h1d
  • 6,042
  • 1
  • 31
  • 46
0
Now it is changed with IOS &

-(IBAction)save:(id)sender
{
        HUD = [[MBProgressHUD alloc] initWithWindow:[[UIApplication sharedApplication] keyWindow]];
        [[[UIApplication sharedApplication] keyWindow] addSubview:HUD];

        HUD.delegate = self;
        HUD.labelText = @"Initiating Entropy...";
        HUD.minSize = CGSizeMake(135.f, 135.f);
        [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}

-(void)myTask
{
    sleep(6);
    UIView *v = [[UIView alloc] init];
    UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"check_mark_green"]];
    [v setFrame:CGRectMake(0, 0, img.frame.size.width, img.frame.size.height)];
    v.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"37x-Checkmark"]];

    HUD.mode = MBProgressHUDModeCustomView;
    HUD.customView = v;
    HUD.labelText = nil;
    HUD.detailsLabelText = @"Geo-Location Cordinates Secured";
 }

try this and enjoy the code.

chandan
  • 2,453
  • 23
  • 31