iOS UIAlertView按钮转到设置应用程序

iOS UIAlertView按钮转到设置应用程序,ios,uialertview,settings.bundle,Ios,Uialertview,Settings.bundle,有没有办法让UIAlertView的按钮转到调用它的特定应用程序的设置应用程序 感谢ios5及以上版本中的 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]]; 例如: NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"]; [[UIApplication sharedApplication] openURL:url];

有没有办法让UIAlertView的按钮转到调用它的特定应用程序的设置应用程序

感谢ios5及以上版本中的

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];
例如:

NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];
[[UIApplication sharedApplication] openURL:url];


显然,这在iOS 5.1中根本不起作用。我整个上午都在与之抗争,然后偶然发现了这个博客


只能从iOS 8以编程方式打开设置应用程序。因此,请使用以下代码…

if([CLLocationManager locationServicesEnabled]&&
   [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied)
{
  //...Location service is enabled
}
else
{
    if([[[UIDevice currentDevice] systemVersion] floatValue]<8.0)
    {
    UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [curr1 show];
    }
    else
    {
        UIAlertView* curr2=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
        curr2.tag=121;
        [curr2 show];
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
 NSLog(@"buttonIndex:%d",buttonIndex);

   if (alertView.tag == 121 && buttonIndex == 1)
 {
  //code for opening settings app in iOS 8
   [[UIApplication sharedApplication] openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];
 }
}
if([CLLocationManager LocationServiceEnabled]&&
[CLLocationManager授权状态]!=kCLAuthorizationStatusDenied)
{
//…已启用位置服务
}
其他的
{

如果([[[UIDevice currentDevice]systemVersion]floatValue]它也可以在iOS8+上工作,但是我们需要改变一些东西

NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];
if([[UIApplication sharedApplication] canOpenURL:url]){
    [[UIApplication sharedApplication] openURL:url];
}

我当时正在测试它,并意识到它只在ios 5上运行。我在iPhone 3G上测试它,而不是在S上。我知道它的老lol。ios 4有什么办法吗?或者它仅限于支持ios 5多任务处理的设备吗?是的,如果你在URL类型中添加一个值为“prefs”的新项,它在ios 6和ios 7中都能工作。我已经在ios 7中测试过它。苹果会批准这项吗打开设置应用程序的方式?工作正常-但您需要将url类型设置为打开首选项:是否可以转到设置应用程序的一般顶级,而不是应用程序的设置选项?否@zonabi,iOS SDK没有提供任何选项。
NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];
if([[UIApplication sharedApplication] canOpenURL:url]){
    [[UIApplication sharedApplication] openURL:url];
}