Search code examples
iosios5uiviewcontrollerviewcontrollermbprogresshud

MBProgress HUD not showing the correct mode always default mode


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) \\

///


Solution

  • 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];