相关疑难解决方法(0)

XCode/iOS模拟器:手动触发重要的位置更改

有没有办法手动告诉设备发送重要的位置变更通知,该通知会唤醒为此通知注册的任何应用程序?这仅用于测试,我意识到这个私有API调用在提交到应用商店时会被拒绝.

iphone core-location cllocationmanager ios

75
推荐指数
2
解决办法
2万
查看次数

startMonitoringSignificantLocationChanges在swift中不起作用

我在AppDelegate文件中使用Swift在我的应用程序中添加了CLLocationManager.

在Appdelegate.swift文件中,

import CoreLocation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
var locationManager: CLLocationManager!
Run Code Online (Sandbox Code Playgroud)

在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()
}
Run Code Online (Sandbox Code Playgroud)

如果我使用startUpdatingLocation,didUpdateLocations方法被调用,但不是startMonitoringSignificantLocationChanges.

为什么没有被要求startMonitoringSignificantLocationChanges.我在ios模拟器中测试这个.我不知道如何检查设备.

cllocationmanager ios ios-simulator swift location-services

8
推荐指数
1
解决办法
5362
查看次数