2010-06-18 82 views
1

所有,CLLocationManagerDelegate方法不在iPodTouch呼叫

我正在使用示例代码,它使用CLLocationManager类来确定用户的当前位置。 当我在iPad上运行这个应用程序时,我获得了正确的位置,但是当我在iPod上运行相同的应用程序时,我触摸到了一个空白标签,即没有任何内容显示在标签上。尽管Wi-Fi信号强度在iPod和iPad.The代码看起来像......

- (void)locationManager:(CLLocationManager *)manager 
didUpdateToLocation:(CLLocation *)newLocation 
     fromLocation:(CLLocation *)oldLocation{ 




    int degrees = newLocation.coordinate.latitude; 

    double decimal = fabs(newLocation.coordinate.latitude - degrees); 
    int minutes = decimal * 60; 
    double seconds = decimal * 3600 - minutes * 60; 
NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"", 
       degrees, minutes, seconds]; 


    latLabel.text = lat; 
    [latLocationArray addObject:lat]; 






degrees = newLocation.coordinate.longitude; 
decimal = fabs(newLocation.coordinate.longitude - degrees); 
minutes = decimal * 60; 
seconds = decimal * 3600 - minutes * 60; 
NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"", 
        degrees, minutes, seconds]; 
longLabel.text = longt; 
[longLocationArray addObject:longt]; 

}

回答

1

这有可能是iPad的是看到WiFi站的iPod Touch上不能看到。 Touch的WiFi范围更小。您是否在一个WiFi站点很少的地区(农村)进行测试。

iPad是3G的型号吗?如果是的话,如果WiFi无法工作,它将使用GPS和手机信号塔。

您是否检查过位置管理器发回给您的任何错误?您以前可能已经禁用了该应用的位置数据,或者可能存在其他一些错误。

+0

但信号强度非常好,虽然我已经检查了效应器 – Siddharth 2010-06-18 15:10:44

+0

-(void)locationManager :(CLLocationManager *)manager didFailWithError :(NSError * )错误 { \t NSLog(@“error =%@”,error); \t } 我现在使用这种方法,但它没有被调用。 – Siddharth 2010-06-18 15:14:45

+2

你自己的WiFi信号强度并不是真正重要的。 WiFi位置的工作原理是查看您周围的所有WiFi站点并尝试查找位于大型数据库中的WiFi站点。数据库与WiFi和位置相匹配,但是如果您附近的WiFi站点都不在该数据库中,则无法获取位置。这就是为什么WiFi密度很重要(即你附近的WiFi站的数量)。这里有一个很好的描述:http://www.skyhookwireless.com/howitworks/ – 2010-06-18 15:19:56

0
int degrees = newLocation.coordinate.latitude; 

double decimal = fabs(newLocation.coordinate.latitude - degrees); 
int minutes = decimal * 60; 
double seconds = decimal * 3600 - minutes * 60; 

你知道当newLocation.coordinate.latitude> = 0时,所有这些阴谋结果都为'0',那么正确吗?

如果newLocation.coordinate.latitude = 90 .....

度= 90
小数= 0; (90-90)
分钟= 0; (0 * 60)
秒= 0; (0 * 3600 - 0 * 60)//假设典型的操作数优先

+0

我不知道...谢谢凯文 – Siddharth 2010-06-21 07:52:44