Opening the Settings app from another app

前端 未结 17 2199
傲寒
傲寒 2020-11-22 01:37

Okay, I know that there are many question about it, but they are all from many time ago.

So. I know that it is possible because the Map app does it.

In the M

17条回答
  •  情深已故
    2020-11-22 02:17

    From @Yatheeshaless's answer:

    You can open settings app programmatically in iOS8, but not in earlier versions of iOS.

    Swift:

       UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
    

    Swift 4:

    if let url = NSURL(string: UIApplicationOpenSettingsURLString) as URL? {
        UIApplication.shared.openURL(url)
    }
    

    Swift 4.2 (BETA):

    if let url = NSURL(string: UIApplication.openSettingsURLString) as URL? {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
    }
    

    Objective-C:

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
    

提交回复
热议问题