xcode IOS 5按钮像主页按钮一样关闭应用程序
我正在编写一个非常简单的应用程序,应该可以快速使用。因此,我想要一个执行某个功能的按钮,然后在该功能完成后导致应用程序退出。
首先,这符合苹果的规则吗?这个区域似乎有点灰色。 其次,如果可以的话我应该使用什么代码?我试过了
[[UIApplication共享应用]terminateWithSuccess];
它确实退出了应用程序,但我有需要在途中保存的数据,并且这个函数永远不会被调用......
-(void)applicationWillTerminate:(NSNotification *)notification
任何提示都会很棒。
I am writing a really simple app which should be quick to use. I therefore want to have a button that performs a function then causes the app to exit once this function is done.
Firstly is this ok with Apple's rules, the area seems a little grey.
And secondly if this is ok what code should I use? I've tried
[[UIApplication sharedApplication] terminateWithSuccess];
which does exit the app but I have data which needs saving on the way and this function never gets called...
-(void)applicationWillTerminate:(NSNotification *)notification
Any tips would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题是这个问题的重复:
退出iPhone应用程序的正确方法?
苹果希望用户通过主页按钮退出(查看该链接问题的高票答案)。
Your question is a dupe of this question:
Proper way to exit iPhone application?
Apple wants the user to do the quitting via the home button (look at the highly voted answer on that linked question).
这个区域并不是“小灰色”。 明确禁止以编程方式退出应用程序。
另外,
terminateWithSuccess
是私有 API,因此明确禁止这样做。This area is not a "little grey". It's explicitly prohibited to quit an app programmatically.
Also,
terminateWithSuccess
is a private API, so this is clearly prohibited.