2

I am trying to initalize the MBProgress HUD with a mode but the progress pops up only with the label not the annular mode.

    //Addition of new HUD progress whilst running the process field entries method
    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];

    // Set determinate mode
    HUD.mode = MBProgressHUDModeAnnularDeterminate;

    HUD.delegate = self;
    HUD.labelText = @"Signing you up";

    // myProgressTask uses the HUD instance to update progress
    [HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES];

I am also getting a warning on the delegate row.

Assigning to 'id<MBProgressHUDDelegate>' from incompatible type 'NewUserViewController *const __strong'

///

This is another example - HUD-test is a simple application I setup to show the full code and issue(second image) \\

///

StuartM
  • 6,743
  • 18
  • 84
  • 160

1 Answers1

2

In order to get rid of the warning, just define your class as an MBProgressHUDDelegate in your header file.

To take care of the correct mode, take a look at the MBProgressHUD.h mode enumeration:

/** Progress is shown using an UIActivityIndicatorView. This is the default. */
MBProgressHUDModeIndeterminate,
/** Progress is shown using a round, pie-chart like, progress view. */
MBProgressHUDModeDeterminate,
/** Progress is shown using a ring-shaped progress view. */
MBProgressHUDModeAnnularDeterminate,
/** Shows a custom view */
MBProgressHUDModeCustomView,
/** Shows only labels */
MBProgressHUDModeText

Select the one you want to show and activate using this code:

   MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 
    [HUD setMode: MBProgressHUDModeAnnularDeterminate]; 
    HUD.delegate = self; 
    HUD.labelText = @"Signing you up"; 
    [HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES];
Stavash
  • 14,244
  • 5
  • 52
  • 80
  • This is taken from the HUD Demo: `code`- (IBAction)showWIthLabelAnnularDeterminate:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; [self.navigationController.view addSubview:HUD]; // Set determinate mode HUD.mode = MBProgressHUDModeAnnularDeterminate; HUD.delegate = self; HUD.labelText = @"Loading"; // myProgressTask uses the HUD instance to update progress [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES]; } `code` In my case I am not using a navigation controller just a uiview – StuartM Aug 29 '12 at 13:10
  • Why not use the "showHUDAddedTo:animated:" method? It's intended for adding the progress HUD to your view. – Stavash Aug 29 '12 at 13:22
  • if i change the code to the following: HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; [self.view addSubview:HUD]; // Set determinate mode HUD.mode = MBProgressHUDModeAnnularDeterminate; HUD.delegate = self; HUD.labelText = @"Signing you up"; // myProgressTask uses the HUD instance to update progress [HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES]; The same issue applies it shows the title text and not the actual HUD mode... – StuartM Aug 29 '12 at 15:06
  • Do you still get the warning? – Stavash Aug 29 '12 at 15:21
  • Yes the warning still occurs. The text doesnt seem to be an issue, it is like the mode is not loading to the HUD. So it defaults back, it is the black box just with text, rather than the Annular mode I set before calling it – StuartM Aug 29 '12 at 15:30
  • I get exactly the same issue on your latest edit. Thanks for your help its appreciated. The HUD still loads but only with text and no annular mode/style. – StuartM Aug 29 '12 at 15:40
  • Just ran it on my simulator and it works... What iOS version are you running on? – Stavash Aug 29 '12 at 15:46
  • Iphone sim 5.1 -- making up the minimum chars – StuartM Aug 29 '12 at 16:02
  • as a side note, you are completely correct in adding the MBProgressHUDdelegate to my header file. this resolves the warning However, the mode remains an issue at the moment. – StuartM Aug 29 '12 at 16:16
  • could you post a screenshot of the resulting progress HUD? – Stavash Aug 29 '12 at 16:21
  • well its difficult as the process completes quickly, let me try sleeping somewhere (not literally) – StuartM Aug 29 '12 at 16:30
  • Does changing the mode to anything else do something? – Stavash Aug 29 '12 at 16:45
  • unfortunately not. I also tried setting the mode as the first thing, but still no avail. [HUD setMode:MBProgressHUDModeText]; HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; HUD.delegate = self; HUD.labelText = @"Signing you up"; [HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES]; -- this is the correct snippet. It seems to just always default – StuartM Aug 29 '12 at 16:53
  • Sounds like this HUD is coming from another place. Try opening a side project just to test this out - place only the relevant code in the "viewDidLoad" and see what happens – Stavash Aug 29 '12 at 17:16
  • appreciate your help, I have done that and the same issue occurs. I have attached two images one showing the view controller code and the other showing the issue, this was a fresh project i just made. – StuartM Aug 29 '12 at 17:49
  • Try this: Set mode BEFORE adding to view. – Stavash Aug 30 '12 at 09:18
  • I am beyond baffled with this, I set up another new project and it worked, copied the code from that to my original and now works?!?!? I will accept your answer as the answer, here is the code I am now using added as an answer, but will accept yours! appreciate all the help, driving me insane and continues... – StuartM Aug 30 '12 at 11:09