【发布时间】:2016-04-29 05:36:15
【问题描述】:
我正在使用 CLLocationManager,问题是当应用程序启动时,然后在 2 秒后(显示 splashScreen 时)按主页按钮,然后应用程序转到后台统计,然后位置弹出窗口仅显示 1 秒并自动隐藏,用户无法单击因为位置弹出窗口自动隐藏,然后应用程序转到后台到前台位置弹出窗口丢失,当我杀死应用程序然后再次打开应用程序弹出窗口显示或一段时间不显示,并且设置屏幕一般没有位置允许选项与否,我在做什么,我的代码哪里有问题,我的问题是 ios 框架 这是我的代码
Plist
<key>NSLocationAlwaysUsageDescription</key>
<string>Get Your Location </string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Get Your Location For </string>
AppDelegate.swift
import CoreLocation
class AppDelegate: UIResponder, UIApplicationDelegate ,CLLocationManagerDelegate {
let locationManager = CLLocationManager()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//NSThread.sleepForTimeInterval(3);
self.initLocationManager();
return true
}
func initLocationManager() {
// locationManager = CLLocationManager()
self.locationManager.delegate = self
self.locationManager.distanceFilter = 40 // Must move at least 1km
self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
//self.locationManager.requestAlwaysAuthorization()
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print(locations)
}
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus)
{
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
print("Error")
}
}
请帮助我,当我从苹果商店下载 ola 应用程序和 Uber 应用程序在此应用程序中检查相同的想法时,在启动屏幕中按下主页按钮时,当应用程序在后台时,弹出窗口保持不变,但在我的代码中我无法做到。请帮我 。
谢谢你 问候, 尼桑特·钱德瓦尼
【问题讨论】:
标签: swift core-location