来自后台的iOS App UI冻结

时间:2016-07-05 17:49:04

标签: objective-c ios9.3.2

我面临一个奇怪的问题,我不知道为什么会发生这种情况。我的应用程序在活动时工作正常,但应用程序UI在来自背景时会被冻结(通过按主页按钮和锁定设备)。

注意:此行为仅在设备上观察到,但不在模拟器中观察到。

控制台正在抛出消息:

Jul  5 13:28:55 Tejas-iPhone backboardd[7234] <Warning>: BKSendHIDEvent: IOHIDEventSystemConnectionDispatchEvent error:0xE00002E8 -- Unknown event dropped

以及太多的日志:

Jul  5 14:41:40 Tejas-iPhone boostApp[7913] <Error>: CoreLocation: Discarding message for event 0 because of too many unprocessed messages
Jul  5 14:41:42 Tejas-iPhone boostApp[7913] <Error>: CoreLocation: Discarding message for event 12 because of too many unprocessed messages
Jul  5 14:44:56 Tejas-iPhone boostApp[7913] <Error>: CoreLocation: Discarding message for event 1 because of too many unprocessed messages
Jul  5 14:44:56 Tejas-iPhone boostApp[7913] <Error>: CoreLocation: Discarding message for event 27 because of too many unprocessed messages

我发现如果locationManager没有在主线程上运行,CoreLocation将记录上述消息。

以下是我初始化CLLocationManager

的方法
-(id)init {
    if ( self = [super init] ) {
        [self runLocationManagerOnMainThread];
    }
    return self;
}

-(void)runLocationManagerOnMainThread{

    if (![NSThread mainThread]) {
        [self performSelectorOnMainThread:@selector(runLocationManagerOnMainThread) withObject:nil waitUntilDone:NO];
    }
    self.locationManager = [[LocationManager alloc] init];
    self.locationManager.delegate = self;
    self.locationManager.distanceFilter = 1;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
    self.buildings = [[NSMutableArray alloc] init];
}

+ (id)sharedInstance {
    static LocationMonitor *sharedMyManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMyManager = [[self alloc] init];
    });
    return sharedMyManager;
}

如果我需要提及任何具体细节,请告诉我。我试过this但它没有任何有效答案。

1 个答案:

答案 0 :(得分:0)

这很奇怪。我不久前将NSLogger集成到我的项目中,我开始看到xcode终端停止记录日志,我必须始终依靠apple配置器和NSLogger查看我的日志。

从pod和我的项目中删除NSLogger后,我的应用程序开始工作得更快,UI不再冻结,无论应用程序从后台打开多少次。