5

如何显示此警报视图?我知道我需要检查可访问性的连接,但是如何使用设置和确定按钮显示此警报?我需要它用于 iOS 6。

在此处输入图像描述

4

1 回答 1

3

不幸的是,在 iOS 5.1 及更高版本中,您无法从您的应用程序中打开设置应用程序。

如果您使用的是较低版本,则以下内容将起作用。

创建警报视图,如:

UIAlertView *cellularData = [[UIAlertView alloc] initWithTitle: @"Cellular Data is Turned Off" message:@"Turn on ellular data or use Wi-Fi to access data"  delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
[cellularData show];

实现clickedButtonAtIndex类似:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if(buttonIndex == 1)
   {
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Network"]]
   }
}

它将从您的应用程序中打开设置应用程序。

于 2012-12-17T10:37:00.153 回答