When B
appears, it displays a plain and empty UITableView
, but does not display the MBProgressHUD
even if the task does begin in the background (and yet, the MBProgressHUD
is called to show before that). Hence, my solution is to show the MBProgressHUD
in viewDidLoad
, which precedes viewWillAppear
.
- (void)viewDidLoad {
// ...
[self displayLoadingAndDisableUI];
}
I set up two additional boolean properties to B
--one in .h, called shouldStartOverUponAppearing
, and one in a class extension in .m, called isLoadingAndDisabledUI
. In startOver
, I added the following lines:
- (void)startOver {
if (!self.isLoadingAndDisabledUI) {
[self displayLoadingAndDisabledUI];
}
}
The check is done so that startOver
doesn't display another MBProgressHUD
when it has already been displayed from viewDidLoad
. That is because I have a third view controller, called C
, that may call on B
's startOver
, but doesn't need to call viewDidLoad
just to display the MBProgressHUD
.
Also, this is how I defined viewDidAppear
:
- (void)viewDidAppear:(BOOL)animated {
if (self.shouldStartOverUponAppearing) {
[self startOver];
self.shouldStartOverUponAppearing = NO;
}
}
This way, startOver
will only be invoked IF B
appeared from A. If B
appears by pressing "Back" in C
, it will do nothing and only display the old data that was there.
I think that this solution is FAR from elegant, but it works. I guess I'll just ask for a better approach in a separate SO question.