关于5.1以前的版本 如以下方式打开的方式:
NSURL *url =[NSURL URLWithString:@"prefs:root=General&path=About"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication]openURL:url];
}
else{
UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"tips" message:@"can,t open this url" delegate:self cancelButtonTitle:nil otherButtonTitles:@"sure", nil];
[alert show];
}
url即设置内通用-关于的链接 不过现在对于早已过去的5.1系统来说 这早已不能使用了 现在有更好的方法
现在的一切都集成到了系统的控件中去了 比如使用定位功能 发现不能使用 系统自动提示是否去设置页面打开定位功能 以下是部分代码:
- (void)requestLocationServicesAuthorization {
self.locationManager = [[CLLocationManager alloc] init];
[self.locationManager setDelegate:self];
/*
When the application requests to start receiving location updates that is when the user is presented with a consent dialog.
*/
[self.locationManager startUpdatingLocation];
}
#pragma mark - CLLocationMangerDelegate methods
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
/*
Handle the failure...
*/
[self.locationManager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
/*
Do something with the new location the application just received...
*/
[self.locationManager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
/*
The delegate function will be called when the permission status changes the application should then attempt to handle the change appropriately by changing UI or setting up or tearing down data structures.
*/
if(status == kCLAuthorizationStatusNotDetermined) {
[self alertViewWithDataClass:nil status:@"未决定"];
}
else if(status == kCLAuthorizationStatusRestricted) {
[self alertViewWithDataClass:nil status:@"已拒绝"];
}
else if(status == kCLAuthorizationStatusDenied) {
[self alertViewWithDataClass:nil status:@"以否定"];
}
else if(status == kCLAuthorizationStatusAuthorized) {
[self alertViewWithDataClass:nil status:@"已授权"];
}
}
这里有官方的代码 自己看一下就明白了
https://developer.apple.com/library/ios/samplecode/PrivacyPrompts/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013410-Intro-DontLinkElementID_2
请叫我雷锋