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

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

问题描述

任何想法?

我发现这样 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天全站免登陆