Search code examples
iphoneiosxcodeipadmbprogresshud

MBProgressHud clears the view when showing the loader


I'm using MBProgressHud to show a load indicator. Here is my display code:

self.hud = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:self.hud];

self.hud.delegate = self;
self.hud.labelText = @"Loading :)";

[self.hud showWhileExecuting:@selector(CreateCollage) onTarget:self withObject:nil animated:YES];

The issue is that when this runs, it clears out the view containing a bunch of photos. This is confusing for my user because they lose visual frame of reference.

If I don't use MBProgressHud, you would see the existing photo set until CreateCollage was finished, and it would kind of just lag or freeze into the next set, which is somewhat OK but not preferred. Any ideas? Thanks


Solution

  • I guess your problem is sourced by initializing it with the view and then adding it to the view again, so it is somehow identical to your view in terms of frame , so it may be getting in front.

    I suggest trying this instead :

    self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.hud.delegate = self;
    self.hud.labelText = @"Loading :)";
    

    And call this at the end of your action which is CreateCollage

    [MBProgressHUD hideHUDForView:self.view animated:YES];