iOS7 CLLocationManager暂停更新,不会继续

iOS7 CLLocationManager暂停更新,不会继续,ios7,core-location,cllocationmanager,Ios7,Core Location,Cllocationmanager,我有一段代码可以在iOS模拟中运行并获得连续的位置更新,但当我在iPad上运行它时,它似乎在第三次更新后停止运行。我尝试将activityType更改为其他或,并设置可能导致其暂停更新的内容,但这些似乎没有帮助。我也不清楚为什么它会在现实生活中停止,而不是在模拟中停止 我确实尝试过在每次更新后都停止更新,然后是startUpdates,这看起来确实有效,但我觉得这是一种糟糕的行为方式。是否有人对此类问题有其他建议或经验 #import "ViewController.h" #import <

我有一段代码可以在iOS模拟中运行并获得连续的位置更新,但当我在iPad上运行它时,它似乎在第三次更新后停止运行。我尝试将activityType更改为其他或,并设置可能导致其暂停更新的内容,但这些似乎没有帮助。我也不清楚为什么它会在现实生活中停止,而不是在模拟中停止

我确实尝试过在每次更新后都停止更新,然后是startUpdates,这看起来确实有效,但我觉得这是一种糟糕的行为方式。是否有人对此类问题有其他建议或经验

#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>

@interface ViewController () <CLLocationManagerDelegate>
@property (nonatomic, strong) CLLocationManager *myLocationManager;
@end

@implementation ViewController

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{

    for (int locIndex = 0; locIndex < locations.count; locIndex++)
    {
        CLLocation *newLocation = [locations objectAtIndex:locIndex];
        NSLog(@"Latitude = %f", newLocation.coordinate.latitude);
        NSLog(@"Longitude = %f", newLocation.coordinate.longitude);
    }
    CLLocationDistance  distance = 0;
    NSTimeInterval timeout = 1;

    [manager allowDeferredLocationUpdatesUntilTraveled:distance timeout:timeout];


}

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation{
    CLLocationDistance  distance = 0;
    NSTimeInterval timeout = 1;

    [manager allowDeferredLocationUpdatesUntilTraveled:distance timeout:timeout];


    /* We received the new location */

    NSLog(@"Latitude = %f", newLocation.coordinate.latitude);
    NSLog(@"Longitude = %f", newLocation.coordinate.longitude);
    //[self.myLocationManager stopUpdatingLocation];
    //[self.myLocationManager startUpdatingLocation];

}

- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error{

    /* Failed to receive user's location */
    NSLog(@"******************************************************");
    NSLog(@"************** FAILED TO RECEIVE LOCATION ************");
    NSLog(@"******************************************************");
}

- (void)viewDidLoad {
    [super viewDidLoad];

    if ([CLLocationManager locationServicesEnabled]){
        self.myLocationManager = [[CLLocationManager alloc] init];
        self.myLocationManager.delegate = self;
        //self.myLocationManager.pausesLocationUpdatesAutomatically = NO;
        //self.myLocationManager.activityType = CLActivityTypeOther;

        [self.myLocationManager startUpdatingLocation];

        //self.myPeripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil];



    } else {
        /* Location services are not enabled.
         Take appropriate action: for instance, prompt the
         user to enable the location services */
        NSLog(@"Location services are not enabled");
    }

}

当用户忘记GPS处于活动状态时,使用暂停。为了防止GPS耗尽电池,在再次启动应用程序之前,GPS会停止并再次打开


您应该接听暂停电话并询问用户位置更新是否应继续

iPad是否有SIM卡,即是否有移动数据?