Reputation: 55
One of the tabs of my UITabBarController takes some time to work before it can be displayed.
What is the best way to display a "Now Loading" before the viewcontroler completes its work?
I tried setting up a "now loading" view in the tab's viewController's viewDidLoad method, then I do the work in viewDidAppear, setting a flag to not do the work again on next time through viewDidAppear.
However, I never see the "now loading" view... some optimizing must be getting done -- the viewcontroller's viewDidAppear is called before the TabBarControllerDelegate didSelectViewController.
Is there a UITabBarController mechanism that would allow for a placeholder view to be displayed before the viewcontroller is displayed?
Any ideas?
Thank you- Matt
Upvotes: 1
Views: 1403
Reputation: 19782
NSObject's performSelector:withObject:afterDelay: method can be useful here. Display your "Please wait" alert or view, or whatever, then use performSelector:withObject:afterDelay: to start the actual work. Your loading will be delayed until after the next execution of the event loop, by which time the user interface will have been redrawn.
Upvotes: 2
Reputation: 12187
The technique to use here is this:
viewWillAppear:
or
viewDidLoad:
methodDoing it this way leaves your application interface still usable, even though the particular view controller is busy.
There are no build in methods to do this, you'll have to code it all yourself.
Upvotes: 1
Reputation: 21882
I could be wrong, but perhaps your problem is that by doing the time-consuming work in viewDidAppear, you're blocking the main event thread so that the view doesn't update until the work is complete. I.e. you set up the "now loading" in viewWillAppear, but you never see it since, by the time viewDidAppear completes, it's done with the heavy work.
Upvotes: 2