2012-03-07 58 views
0


我正在制作一个增强现实应用程序。
基本上我所拥有的是带有来自相机,雷达视图和屏幕上某些标记的图像的屏幕。
我正在使用CLLocationManager来获取我的标题和位置的更新。
我需要航向更新始终打开,因为雷达的旋转取决于它。我正在使用位置更新来获取我的位置,并基于此我正在寻找要显示的标记。
问题是,当我开机时iPhone在一段时间内(10 + - 分钟)过热了一点。我已经将精度设置为每100米,距离过滤器设置为100.
我应该设置一个计时器来停止并开始更新位置以防止过热(并且可能还会节省一些电池寿命)?有没有其他方法呢?
感谢您的建议。CLLocationManager过热iPhone

+0

它听起来像你在某种程度上过度CPU。我曾经有一款应用程序被诺基亚手机的CPU循环卡住,并且过热足以软化将屏幕粘在一起的胶水。确保您的应用程序不在“旋转循环”中,而应该在等待事件发生。 – 2012-03-07 01:29:37

+0

@HotLicks我不认为这是不好的:),我的意思是它很温暖(iPhone并不真正加热,所以它很奇怪,我看到它温暖)在相机的右上角(可能是有核心位置也)。我会按照Kendall的建议检查时间分析器,看看会发生什么 – haluzak 2012-03-07 08:44:41

回答

1

这是一个非常好的时间,用户的“时间探查器”工具

 locationController = [[MyCLController alloc] init]; 
locationController.delegate = self; 
[locationController.locationManager startUpdatingLocation]; 
locationManager = [[CLLocationManager alloc] init]; 
locationManager.delegate = self; 
[locationManager startUpdatingLocation]; 
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; 
showCurrentLocation = NO; 

委派功能。我确定使用GPS对某些热量负责,但是您可以轻松地使用CPU或GPU过多的其他代码部分。

还有一个OpenGL的性能工具,我会看看,看看你是否可以找到任何太费税的零件。

另一种可能性是考虑使用AVFoundation获取相机图像,并查看是否可以为覆盖的视频图像指定较便宜的预览参数。

-1
- (id) init 
    { 
self = [super init]; 
if (self != nil) 
{ 
    self.locationManager = [[CLLocationManager alloc] init]; 
    self.locationManager.delegate = self; 

} 
return self; 
    } 
    - (void)locationManager:(CLLocationManager *)manager 
didUpdateToLocation:(CLLocation *)newLocation 
     fromLocation:(CLLocation *)oldLocation 
{ 
NSLog(@"Location: %@", [newLocation description]); 
[self.delegate locationUpdate:newLocation]; 
} 
- (void)locationManager:(CLLocationManager *)managerdidFailWithError:(NSError *)error; 

{  
[self.delegate locationError:error]; 
NSLog(@"Error Error: %@",[error description]); 
} 

这些委托功能的B类MyCLConrolleer.m电话。

像这样在ViewController类中分配这个类。在视图控制器类

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 
    [self getLocationNameWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude]; 
    }