Last active
January 9, 2019 04:09
-
-
Save ysam12345/61262777315ff2d4188dab232791aed3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locationManager = CLLocationManager() | |
if CLLocationManager.authorizationStatus() == .notDetermined { | |
locationManager.requestAlwaysAuthorization() | |
} | |
// 2. 用戶不同意 | |
else if CLLocationManager.authorizationStatus() == .denied { | |
DispatchQueue.main.async(){ | |
let alertController = UIAlertController(title: "定位權限已關閉", message: "如要變更權限,請至 設定 > 隱私權 > 定位服務 開啟", preferredStyle: .alert) | |
let okAction = UIAlertAction(title: "ok", style: .default, handler: nil) | |
alertController.addAction(okAction) | |
self.present(alertController, animated: true, completion: nil) | |
}//DispatchQueue | |
} | |
// 3. 用戶已經同意 | |
else if CLLocationManager.authorizationStatus() == .authorizedAlways { | |
locationManager.startUpdatingLocation() | |
} | |
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(MapTableViewController.mapLongPress(_:))) // colon needs to pass through info | |
longPress.minimumPressDuration = 1.0 // in seconds | |
mapView.addGestureRecognizer(longPress) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment