0
ユーザーの所在地を取得する私の機能では、許可メッセージがユーザーから必要なアクセス許可を得るチャンスを失わないように警告を出すための事前許可を作成しました。セクションでSwift Pre-permission Overlay
func getCurrentLocation() {
// Init LocationManager
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy =
kCLLocationAccuracyThreeKilometers;
let alert = UIAlertController(title: "Allow Loction Services?",
message: "This allows the app to your loction",
preferredStyle: .alert)
let ok = UIAlertAction(title: "Allow", style: .default, handler: {
(action) -> Void in
self.showHUD("loading...")
if locationManager.responds(to:
#selector(CLLocationManager.requestWhenInUseAuthorization)) {
locationManager.requestAlwaysAuthorization()
}}
self.hideHUD()
)
}
let cancel = UIAlertAction(title: "Not Now", style: .destructive,
handler: { (action) -> Void in })
alert.addAction(ok); alert.addAction(cancel)
present(alert, animated: true, completion: nil)
locationManager.startUpdatingLocation()
}
:
let ok = UIAlertAction(title: "Allow", style: .default, handler: { (action) -> Void in self.showHUD("loading...")
エラーは、私たちは声明のでスウィフト、コンパイラはあなたにそのエラーを与えている「という表現のタイプは、よりコンテキストなしで曖昧である」