下次运行时保持 ipad/iphone 应用程序的状态
假设我正在运行我的iphone/ipad应用程序,我的错误,我按了home键,然后我再次运行我的应用程序,它像往常一样启动,我不希望它像往常一样启动,我想它从我按下之前的状态开始主页键。
**简而言之,当我下次运行时,应该保持应用程序的状态。
Suppose i am running my iphone/ipad application my mistake i pressed home key and again i am running my application it started as usual to i don't want to it started as usual i want to it start from the state where i was before pressing home key.
**In short it should be maintain the state of application while i am running next time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在应用程序委托 .m 文件内的函数
- (void)applicationDidEnterBackground:(UIApplication *)application
中,确保不调用exit
函数。当按下主页按钮时,将运行此函数中的任何内容。in the function
- (void)applicationDidEnterBackground:(UIApplication *)application
inside your application delegate .m file, be sure that you don't call theexit
function. when the home button is pressed, anything in this function will be ran.从 iphone 4.1 和 ipad 4.2 开始,此行为是默认的。如果你不想要它,你实际上必须专门停止它。您正在构建什么版本?
如果它是最新版本,那么就像 binnnyb 所说的那样,请查看
applicationDidEnterBackground
和applicationWillResignActive
中是否有会崩溃或结束应用程序的函数。此外,
exit();
也不是应用商店安全的。This behaviour is default as of iphone 4.1 and ipad 4.2. YOu actually have to specifically stop it if you didn't want it. What version are you building for?
If it is the latest build, then like what binnnyb said, ahve a look in
applicationDidEnterBackground
andapplicationWillResignActive
for functions that will crash or end your app.Also
exit();
is not app store safe.在
NSApplicationDelegate
中实现- (void)applicationWillResignActive:
以保存应用程序状态。然后您可以在启动时重新加载保存的状态。Implement
- (void)applicationWillResignActive:
in yourNSApplicationDelegate
to save your application state. You can then reload the saved state at startup.