iPhone:使用 [[UIApplicationsharedApplication]terminateWithSuccess] 退出应用程序;

发布于 2024-09-26 01:32:08 字数 439 浏览 2 评论 0原文

我构建了一个小型应用程序,可以从网站上的数据库获取信息。 应用程序做的第一件事是获取 RSS 提要,然后显示它。

苹果指南要求让用户决定是否要连接到互联网,因此我在开头放置了一个警报,显示“该应用程序将连接到互联网。继续吗​​?”有两个按钮:“是”和“否,退出”

如果用户选择“否,退出”,那么我会调用:

[[UIApplication sharedApplication] terminateWithSuccess];

It Works。但我读到苹果不鼓励这样做(不是官方 API???),终止应用程序的唯一方法应该是使用 Home 按钮。

我尝试了一个替代方案:如果用户按“不,退出”,我只需显示一个标签,上面写着“使用主页按钮退出应用程序”......

那么,我应该做什么?离开警报并退出应用程序或仅显示“请退出”标签???

I have built a small app that gets informations from a database on a website.
the first thing the app does is to fetch an rss feed and then display it.

Apple guidelines tell to let the user decide if he/she wants to connect to the Internet, so I have placed an alert at the beginning showing "The app will connect to the Internet. Continue?" with two buttons: "Yes", and "No, quit"

if the user chooses "No, Quit", then I call:

[[UIApplication sharedApplication] terminateWithSuccess];

It Works. But I have read that Apple disencourage that, (Not an official API???) and that the only way to terminate an app should be the use of the Home button.

I tried an alernative: if the user press "No, Quit" I simply show a label that says "Quit the app using the Home Button"...

So, what should I do? leave the alert and quit the app or just show the "please quit" label???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七秒鱼° 2024-10-03 01:32:08

你永远不能主动终止你的应用程序,否则苹果将拒绝该应用程序(我根据经验知道;-)。您唯一能做的就是显示一个对话框,例如没有任何按钮的 UIAlertView,要求用户通过主页按钮退出。

但我从未听说过您引用的有关互联网连接的指南。请给一个链接。我开发了很多无需询问就可以连接到互联网的应用程序,苹果从未抱怨过。

You may never actively terminate your app, otherwise Apple will reject the app (I know by experience ;-). Only thing you can do is show a dialog, e.g. a UIAlertView without any buttons, asking the user to quit via home button.

But I never heard about the guidelines you've cited regarding an Internet connection. Please give a link. I've worked on a lot of apps that connect to the Internet without asking and Apple never complained.

暖风昔人 2024-10-03 01:32:08

只需保留“否”按钮即可。

用户要么点击“是”并连接,要么用户通过切换到另一个应用程序来终止(或后台)您的应用程序,因为他们别无选择。

通过简单地强迫用户做一些合理的事情来终止应用程序。

Just leave off the "No" button.

Either the user will hit "Yes" and connect, or the user will terminate (or background) your app by switching to another app, since they have no other choice.

App termination by simply forcing the user to do something reasonable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文