How can I open the Settings app when the user presses a button?

后端 未结 6 1564
不知归路
不知归路 2020-12-06 06:38

From what I understand by using code like this:

NSURL* appUrl = [NSURL URLWithString: @\"URL\"];
[[UIApplication sharedApplication] openURL:appUrl];
<         


        
6条回答
  •  死守一世寂寞
    2020-12-06 07:33

    Swift 3

    private func showAlertPrivacy() {
        let alertController = UIAlertController(title: nil, message: "messagePrivacy", preferredStyle: .alert)
        let alertNo = UIAlertAction(title: "No", style: .default) { (_) in
    
        }
        alertController.addAction(alertNo)
    
        let alertSetting = UIAlertAction(title: "Settings", style: .default) { (_) in
    
            UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!, options: [:], completionHandler: { (_) in
    
            })
        }
        alertController.addAction(alertSetting)
    
        present(alertController, animated: true) { 
    
        }
    }
    

提交回复
热议问题