2013-08-21 50 views
0

我想在使用CCLocationManager时模拟失败。我今天使用的代码就是这样的。使用CCLocationManager模拟失败

首先启动位置更新thingy。

[locationManager startUpdatingLocation]; 

如果东西失败

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{ 
    [locationManager stopUpdatingLocation]; 
    [[ActivityIndicator sharedInstance] hide]; 
} 

然而,东西永远不会失败,似乎和我想从模拟的LocationManager一个真正的错误。问题的根源在于我有一些用户表示,由于ActivityIndi​​cator阻碍,位置搜索从不会结束,导致出现块。

任何提示?

回答

0

我在ipod touch 4g上经历了同样长的位置测量时间。
而不是尝试以手动方式触发didFailWithError,尝试使用延迟30s的NSTimer(应该没事,可以根据需要调整),调用stopupdatinglocation,隐藏您的活动指示符并向用户显示错误消息。