Open Twitter settings in Settings app

后端 未结 6 1746
野的像风
野的像风 2020-12-28 09:02

I know I can open the settings app in iOS 5 using

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\"prefs://\"]];

but is

6条回答
  •  遥遥无期
    2020-12-28 09:29

    The awesome answers are already given but here is the complete snippet to open twitter settings in Settings using UIAlertController and Swift 3 :

     let alert = UIAlertController(title: "No Twitter Accounts", message: "There are no Twitter accounts configured. You can add or create a Twitter account in Settings.", preferredStyle: .alert)
            let firstAction = UIAlertAction(title: "Cancel", style: .default, handler: {(action: UIAlertAction) -> Void in
    
            })
            let secondAction = UIAlertAction(title: "Settings", style: .default, handler: {(action: UIAlertAction) -> Void in
    
                let url = URL(string:"App-Prefs:root=TWITTER")!
                if #available(iOS 10.0, *) {
                    UIApplication.shared.open(url, options: [:], completionHandler: nil)
                } else {
                    UIApplication.shared.openURL(url)
                }
            })
            alert.addAction(firstAction)
            alert.addAction(secondAction)
            self.present(alert, animated: true, completion: nil)
    

提交回复
热议问题