2015-08-14 41 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!謝謝 :) –

相關問題