当我的应用程序再次变为活动状态时,我收到错误消息。它从背景返回。
我猜它是我的陀螺仪,但还没有找到解决方案。
我的错误:
-[WebDataSource onGeomagneticModel:]: unrecognized selector sent to instance 0x37c430
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WebDataSource onGeomagneticModel:]: unrecognized selector sent to instance 0x37c430'
我的applicationDidEnterBackground:
- (void)applicationDidEnterBackground:(UIApplication *)application{
NSLog(@"Application moving to background");
LocationManagerDelegate *locationController = [[LocationManagerDelegate alloc] init];
[locationController.locationManager stopUpdatingHeading];
[locationController stopDeviceMotion];
}
答案 0 :(得分:1)
看起来您创建了另一个LocationManagerDelegate实例。 所以..你没有转过的“旧”实例。
您应该添加.h文件
@property (nonatomic, retain) LocationManagerDelegate *locationController;
然后在.m文件中添加@implementaion
@synthesize locationController=locationController_;
你在哪里创建你的LocationManagerDelegate你需要以某种方式改变它(你没有发布那部分代码):
self.locationController = [[[LocationManagerDelegate alloc] init] autorelease];
然后将您的代码更改为:
- (void)applicationDidEnterBackground:(UIApplication *)application{
NSLog(@"Application moving to background");
[self.locationController.locationManager stopUpdatingHeading];
[self.locationController stopDeviceMotion];
}