开发者

How to Terminate a App on a custom Case. iOS4

My App needs a Internet Connection which is checkt in the ViewDidLoad if there is no Internet connection I want to terminate the app when the Home Button is clickt so that the app start in its initial state next time but only in this case. If there is a Internet connection from the start the homeButton should bring th开发者_高级运维e app just to the background.


Apple does strongly discourages quitting from application programmatically.

I think you can handle your case without quitting application - when application goes to background(in applicationDidEnterBackground method of application delegate) save some flag indicating that you want to reinit it on resume, then when application comes back to foreground (applicationWillEnterForeground method in delegate) apply your initialization logic in case flag is set.


Programatically terminate an App is a behaviour that will be rejected to be published in the AppStore, as it seems that the application crashed.

If you don't mind that your application will never see the light at the AppStore, you can simply use exit(0).


When your app does not find an internet connection, switch to a view that exactly imitates your Default start-up image, then force that view to stay visible the usual amount of start-up time after any call to making your app active. You can also kill and recreate fresh all your other MVC objects during this time.

That way, no one will know that your app wasn't freshly started when brought back from the background.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜