简体   繁体   English

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

[英]How to reboot or reload iPhone app programmatically in iOS

I have dowloaded an xml file that contains some update parameters and then I need to reload these parameters and init some views. 我已经下载了一个包含一些更新参数的xml file ,然后我需要重新加载这些参数并初始化一些视图。 Easiest way is to apply this configuration on next app boot. 最简单的方法是在下次应用程序启动时应用此配置。 Is there any way to reboot iOS application programmatically? 有没有办法以编程方式重启iOS application程序?

Thank you. 谢谢。

Rebooting the app is a bad idea, I'm pretty sure Apple would reject it. 重新启动应用程序是一个坏主意,我很确定Apple会拒绝它。 However, You could display a popup telling the user to open a close the app to apply your updated information. 但是,您可以显示一个弹出窗口,告诉用户打开关闭应用程序以应用更新的信息。 But the best way would be just to manually call the methods needed to rebuild your app (Ie the ones that need to use the updated data). 但最好的方法是手动调用重建应用程序所需的方法(即需要使用更新数据的方法)。 If you have to do some extensive rebuilding (ie things that the user would immediately notice) it might be a good idea to add in a "loading" progress bar of sorts. 如果你必须进行一些大规模的重建(即用户会立即注意到的事情),那么添加一个“加载”进度条可能是一个好主意。

你不能重启你的应用程序,我不明白为什么你会a)必须b)想要的。

You can quit and restart an iOS app with a bit of user assistance. 您可以通过一些用户帮助退出并重新启动iOS应用程序。 Set the app's plist key for application exits on suspend. 在挂起时为应用程序退出设置应用程序的plist键。 Create a local notification for your app to trigger a few seconds into the future. 为您的应用创建本地通知,以便在未来几秒内触发。 Then send Safari a URL. 然后向Safari发送一个URL。 The OS will terminate your app when launching Safari to handle the URL. 启动Safari以处理URL时,操作系统将终止您的应用程序。 The URL might be to a web landing page telling the user that a relaunch is in progress. 该URL可能是一个Web登录页面,告诉用户重新启动正在进行中。 Then the local notification will go off and ask the user to relaunch your app. 然后本地通知将会响起并要求用户重新启动您的应用。

However an app should be (re)designed so that there is never a reason to do this. 但是应该(重新)设计应用程序,以便没有理由这样做。

You can do it only if your device is jailbroken 只有当您的设备被越狱时,您才能这样做

Put a reboot button in your app and call abort(); 在您的应用程序中放置一个重启按钮并调用abort(); . This will crash the app. 这会使应用程序崩溃。

Hook the -(void)exitedAbnormally ; 挂钩-(void)exitedAbnormally ; from SBApplication and write code to launch your app. SBApplication和编写代码来启动您的应用程序。

If its not jailbroken, you have no choice 如果它没有越狱,你别无选择

if you develop for jailbroken devices you can use uicache command to clean the springboard cache and reload new apps/icons (available from UIKit package). 如果您为越狱设备开发,您可以使用uicache命令清理跳板缓存并重新加载新的应用程序/图标(可从UIKit包中获得)。

for example, 例如,

1) if you're under root: 1)如果你在root下:

    su mobile -c uicache 1>/dev/null 2>&1

2) if you're under mobile: 2)如果你在移动:

    uicache

for reboot you can use reboot command under root and killall SpringBoard for respring 对于重启,您可以在root和killall SpringBoard下使用reboot命令进行重新reboot

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM