所有,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];
}
但信号强度非常好,虽然我已经检查了效应器 – Siddharth 2010-06-18 15:10:44
-(void)locationManager :(CLLocationManager *)manager didFailWithError :(NSError * )错误 { \t NSLog(@“error =%@”,error); \t } 我现在使用这种方法,但它没有被调用。 – Siddharth 2010-06-18 15:14:45
你自己的WiFi信号强度并不是真正重要的。 WiFi位置的工作原理是查看您周围的所有WiFi站点并尝试查找位于大型数据库中的WiFi站点。数据库与WiFi和位置相匹配,但是如果您附近的WiFi站点都不在该数据库中,则无法获取位置。这就是为什么WiFi密度很重要(即你附近的WiFi站的数量)。这里有一个很好的描述:http://www.skyhookwireless.com/howitworks/ – 2010-06-18 15:19:56