2015-08-14 45 views

回答

5

你想看看

func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) 

CLLocationManager.authorizationStatus() 

首先,当用户更改授权状态,第二个会允许你在任何时候确定当前状态被调用。

然后,显示该消息,例如:

let alert = UIAlertController(title: "Your title", message: "GPS access is restricted. In order to use tracking, please enable GPS in the Settigs app under Privacy, Location Services.", preferredStyle: UIAlertControllerStyle.Alert) 
      alert.addAction(UIAlertAction(title: "Go to Settings now", style: UIAlertActionStyle.Default, handler: { (alert: UIAlertAction!) in 
       print("") 
       UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!) 
      })) 

上面的代码示出了警报,并允许用户直接去设置以启用位置。

+0

非常棒的帮助,@MirekE!谢谢 :) –

相关问题