gpt4 book ai didi

ios - 强制应用程序在 iPhone 中终止

转载 作者:可可西里 更新时间:2023-11-01 04:04:21 26 4
gpt4 key购买 nike

我正在开发一个完全基于网络数据的 iPhone 应用程序。

如果未连接到互联网,则该应用程序没有用。

所以,我想在找不到连接时终止应用程序。

NSURL *tmpURl=[NSURL URLWithString:[NSString stringWithFormat:@"%@search.php",[iGolfAppDelegate getServerPath]]];
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:tmpURl];
con=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(con){
myWebData=[[NSMutableData data] retain];
} else {
//Yes I will provide two buttons on alertview "retry" & "close", & when user
//taps on "close" => application should terminate.
// i will send alertview & when user taps on button close then
// what to write for terminating application?
// Ok Ok. Don't terminate. User will terminate.
// user is owner of iPhone
// let him choose what to do
// wait till wifi connects
}

问题是如何终止应用程序?

exit(0) 只是终止应用程序的选项还是有其他可用选项?

最佳答案

Apple 对这个话题非常清楚:

There is no API provided for gracefully terminating an iPhone application. Under the iPhone OS, the user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take - turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.

参见 Technical Q&A QA1561

关于ios - 强制应用程序在 iPhone 中终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1841824/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com