Tôi đã thêm CLLocationManager vào ứng dụng của mình bằng Swift trong tệp AppDelegate.startMonitoringSignificantLocationChange không hoạt động trong swift
Trong tập tin Appdelegate.swift,
import CoreLocation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
var locationManager: CLLocationManager!
Trong phương pháp didbecomeActive:
func applicationDidBecomeActive(application: UIApplication) {
if((locationManager) != nil)
{
locationManager.stopMonitoringSignificantLocationChanges()
locationManager.delegate = nil
locationManager = nil
}
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.activityType = CLActivityType.OtherNavigation
locationManager.requestAlwaysAuthorization()
locationManager.startMonitoringSignificantLocationChanges()
}
Nếu tôi sử dụng startUpdatingLocation
, phương pháp didUpdateLocations
được gọi, nhưng không phải cho startMonitoringSignificantLocationChanges
.
Tại sao nó không được gọi cho startMonitoringSignificantLocationChanges
. Tôi đang thử nghiệm tính năng này trong trình mô phỏng ios. Tôi không biết cách kiểm tra thiết bị.
có thể trùng lặp: http://stackoverflow.com/questions/8682683/can-i-test-significant-change-with-xcode-simulator – adolfosrs