【发布时间】:2016-07-05 17:49:03
【问题描述】:
我遇到了一个奇怪的问题,我不知道为什么会发生这种情况。我的应用在处于活动状态时运行良好,但是当它来自后台时(通过按下主页按钮并锁定设备)。
注意:此行为仅在设备上观察到,而在模拟器中观察不到。
控制台正在抛出消息:
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,但没有任何有效答案。
【问题讨论】:
-
这个问题是否总是在设备中重复?
-
是的。每次您让应用程序进入后台并再次打开它时,应用程序都会冻结。
标签: objective-c ios9.3.2