如何以编程方式在iOS中重新启动iPhone应用程序 [英] How programmatically restart an iPhone app in iOS

查看:168
本文介绍了如何以编程方式在iOS中重新启动iPhone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式在iOS中重新启动iPhone应用程序?

How programmatically restart an iPhone app in iOS?

我以这种方式找到 http://writeitstudios.com/david/?p=54

但是可能很简单.

推荐答案

我知道的唯一方法不是理想的方法,但它可行.

The only way I know to do this is not ideal, but it works.

首先,您的应用程序必须选择退出后台执行(多任务).应用程序必须在退出时退出,而不是作为后台任务运行.这是通过plist键UIApplicationExitsOnSuspend完成的.

First, your app has to opt out of background execution (multitasking) The app has to quit when exited, not run as a background task. This is done with the plist key UIApplicationExitsOnSuspend.

第二,您的应用程序需要注册可用于启动应用程序的自定义URL方案.

Second, your app needs to register a custom URL scheme that can be used to launch the app.

第三,您需要一个托管在某个位置的网页,该网页在加载后将重定向到您应用的自定义URL方案.

Third, you need a web page hosted somewhere that when loaded will redirect to your app's custom URL scheme.

第四,用户需要有效的Internet连接.

Forth, the user needs an active Internet connection.

要退出并重新启动,请在托管的重定向网页上调用UIApplication openURL.您的应用将退出,而safari将启动并加载您的页面.该页面会将Safari重定向到您的自定义URL方案,提示Safari内部调用openURL,从而导致iOS启动您的应用.

To exit and restart, call UIApplication openURL on your hosted redirecting web page. Your app will exit and safari will launch and load your page. The page will redirect Safari to your custom URL scheme, prompting Safari to internally call openURL, causing iOS to launch your app.

这篇关于如何以编程方式在iOS中重新启动iPhone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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