2012-04-13 58 views
1

我的應用程序再次變爲活動狀態時出現錯誤。它從背景返回。未捕獲的異常: - [WebDataSource onGeomagneticModel:]:無法識別的選擇器

我猜測我的陀螺儀,但還沒有找到解決方案。

我的錯誤:

-[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]; 


} 

回答

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]; 
} 
+0

Doh,我很着急解決其他問題,我沒有看到...謝謝 – Lohardt 2012-04-13 10:57:12

相關問題