按下一个按钮,它将我带到Apple设置应用程序

时间:2015-06-22 11:11:08

标签: ios swift ios8 xcode6

当我按下一个按钮,它将我带到Apple设置应用

时该怎么办?

像这样...... 但它让我进入我的应用程序设置

我想去常用的设置应用

使用Swift

    @IBAction func settingsApp() {
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
}

2 个答案:

答案 0 :(得分:1)

试试这个

if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) {

} else {
    //iOS 8 specific code here
    [self openSettings];
}


- (void)openSettings
{
    BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);
    if (canOpenSettings) {


        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        [[UIApplication sharedApplication] openURL:url];
    }
}

答案 1 :(得分:0)

@IBAction func settingsApp(sender: UIButton) {
    let appSettings = NSURL(string: UIApplicationOpenSettingsURLString)
    if let gotoUrl = appSettings {
        UIApplication.sharedApplication().openURL(gotoUrl)
    }
}