UIAlertView like “Turn On Location Services to allow maps to determine your location”. Settings + Cancel

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

I Want to emit this alert:

Turn On Location Services to allow maps to determine your location 

I need both "Settings" and "Cancel" exactly like the "maps" application.

"Settings" should open settings->general->location services

I didn't find the way to open the settings page.

Can you help me?

Thanks

回答1:

Creating the alert is pretty straightforward, it's just a (faux-)modal UIView.

However, it's not possible to open the Settings app programmatically, at least not without using private methods that will prevent your app from being approved for the App Store.



回答2:

This is not possible to accomplish on your own. However, if your application needs to access location services the OS will present a dialog like this for you as seen below.

Edit: Brant mentioned below that "the message can be customized by setting the value of the purpose property on your CLLocationManager."



回答3:

You can't open specific settings page like General, Locatios etc., but you can open settings page in iOS 8.

  - (void)openSettings   {       BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);       if (canOpenSettings)       {           NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];           [[UIApplication sharedApplication] openURL:url];       }   } 


回答4:

It's not possible to open the setting pane programmatically at this moment. Refer to here.



回答5:

It's not something you add. That screen comes up when the applications wants to use locational services but it's turned off in the settings.

The same thing happens with push notifications.



回答6:

Swift 2.0 version:

func showLocationSettingAlert() {     let alertController = UIAlertController(         title:  "Location Access Disabled",         message: "Location settings",         preferredStyle: .Alert)      let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)     alertController.addAction(cancelAction)      let openAction = UIAlertAction(title: "Open Settings", style: .Default) { (action) in         if let url = NSURL(string:UIApplicationOpenSettingsURLString) {             UIApplication.sharedApplication().openURL(url)         }     }     alertController.addAction(openAction)     self.presentViewController(alertController, animated: true, completion: nil) } 


回答7:

How other said, you can't open Settings app programmatically if you want your app on the App Store.
This popup is automatically "generated" at launch of your app if it support and uses a determined functions like Location Service.
You can find more informations about this service on the Reference Library: https://developer.apple.com/library/ios/navigation/#section=Frameworks&topic=CoreLocation



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!