在位置更新方法上创建线程时,应用程序挂起

时间:2013-09-20 13:41:45

标签: iphone ios multithreading ipad cllocationmanager

//在视图中加载...

self.locationManager =  [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = kCLHeadingFilterNone;// kCLHeadingFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;


- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation     *)newLocation fromLocation:(CLLocation *)oldLocation
{
if (newLocation.course >= 0)
{
    [NSThread detachNewThreadSelector:@selector(showAlertsIfNeededThread) toTarget:self withObject:nil];

}
}

- (void) showAlertsIfNeededThread
{
@autoreleasepool
{
    NSLog(@"Thread started........");
    [NSThread sleepForTimeInterval:3.0];
    //[self showAlertsIfNeeded];
    [self performSelectorOnMainThread:@selector(showAlertsIfNeeded) withObject:nil waitUntilDone:NO];
}
}

执行一些线程后,线程没有执行。应用程序挂起。 任何人都可以帮助我。

提前致谢。

0 个答案:

没有答案