以编程方式阻止应用程序在后台iOS中运行 [英] programmatically prevent app from running in background iOS

查看:114
本文介绍了以编程方式阻止应用程序在后台iOS中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将在后台运行的应用程序,但有一种情况我不希望这种情况发生,我能以编程方式实现吗?

I have an app that will run in the background but there is one case where I do not want that to happen, can I achieve this programmatically?

我知道我可以通过改变选择退出这个plist 值但是在运行时怎么样?

I know I can opt out by changing this plist value but what about at run time?

推荐答案

你不能使用exit(0)b / c apple不允许您在用户不知情的情况下关闭应用程序。

You can't use exit(0) b/c apple does not allow you to close the app without user knowing it.

来自Technical Q& A QA1561 如何以编程方式退出我的iPhone应用程序?

From Technical Q&A QA1561 How do I programmatically quit my iPhone application?.


没有提供API来正常终止iPhone
申请表。在iPhone OS下,
用户按下Home按钮关闭
应用程序。如果您的应用程序
的条件不能为
提供其预期功能,那么
建议的方法是为用户显示
警报,指示
性质用户可以采取的问题和可能的
操作 - 在WiFi上转换
,启用位置服务,
等。允许用户自行决定终止
申请。

There is no API provided for gracefully terminating an iPhone application. Under the iPhone OS, the user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take - turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.

这篇关于以编程方式阻止应用程序在后台iOS中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆