Sreehari
Sreehari

Reputation: 201

UIview while loading didFinishLaunchingWithOptions

I have an application in which the didFinishLaunchingWithOptions of my app delegate register for push notifications. This registration is taking little time, so at launching the app. i need to wait with a blank screen till it register. This waiting time i need to show a "please wait..." message, how can i do this? I have added a UIView before the registration code in didFinishLaunchingWithOptions but it only shows after registration. Plz help

Upvotes: 1

Views: 2353

Answers (3)

XMLSDK
XMLSDK

Reputation: 259

Show a UIAlertView and UIActivityIndicatorView and then use performSelector:withObject:afterDelay: with delay 0.0 to invoke your register code. The indicator will be first animating and your register code can run in the same thread. The delay 0.0 allows a little short break for the indicator to start its animation redrawing process first.

Upvotes: 0

Joey Hagedorn
Joey Hagedorn

Reputation: 2408

Perhaps I'm misinterpreting your question, but it sounds like you're doing some sort of blocking activity in your -[UIApplication didFinishLaunchingWithOptions:] method. You should restructure your code such that you use an asynchronous strategy, so that you don't need to spend a long time waiting inside the didFinishLaunchingWithOptions method. Nothing will be displayed until after that method has completed execution anyway.

When you say your are registering for push notifications, perhaps you could be more specific and post an example of your method implementation? Simply calling -[UIApplication registerForRemoteNotificationTypes:] is non-blocking, so it would not cause the symptom you describe above.

It is important to perform any processing that could take time, such as synchronous network I/O, on a background thread to avoid blocking the main thread, which takes care of the user interface.

Upvotes: 1

zpasternack
zpasternack

Reputation: 17898

The iPhone Human Interface Guidelines suggest providing a default image which looks similar to your first view, which . Many Apple apps do this. See here: Launch Images

I would try this before going so far as to have a "please wait" message.

Upvotes: 0

Related Questions