简体   繁体   English

monotouch iphone以编程方式进入手机主屏幕

[英]monotouch iphone programmatically go to phone home screen

I searched a lot and didn't find how to programmatically bring application to background so phone's home screen is shown. 我搜索了很多,但没有找到如何以编程方式将应用程序带到后台,因此显示了手机的主屏幕。 I don't want to terminate app, but just to programmatically make press on HOME button. 我不想终止应用程序,只是以编程方式按下HOME按钮。 Is there any way to do it? 有什么办法吗?

Unfortunately, there is no background mode in iOS where the app can still run things while out of focus. 不幸的是,iOS中没有后台模式,应用程序仍然可以在失焦时运行。 Apple has designed the system to "pause" the application so state is preserved, but be careful the app can be terminated at any time. Apple已将系统设计为“暂停”应用程序,以便保留状态,但要小心,应用程序可以随时终止。

No, unfortunately not. 不,不幸的是没有。 There is no public API that allows you to send a user back to the homescreen. 没有允许您将用户发送回主屏幕的公共API。

As shown in these questions: 如以下问题所示:

Brad Larson provides a detailed explanation to the answer of this question: Brad Larson对这个问题的答案提供了详细的解释:

You can do this by calling a private API but beware as said above Apple does not allow this on AppStore apps. 你可以通过调用一个私有API来做到这一点,但要注意上面说苹果不允许在AppStore应用程序上这样做。

var x = UIApplication.SharedApplication;
x.PerformSelector (sel: new MonoTouch.ObjCRuntime.Selector ("suspend"), obj: x, delay: 5);

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

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