回答
在你的@implementation添加这些变量:
CLLocationManager *manager;
CLGeocoder *geocoder;
在您的viewDidLoad:
manager = [[CLLocationManager alloc] init];
geocoder = [[CLGeocoder alloc] init];
manager.delegate = self;
manager.desiredAccuracy = kCLLocationAccuracyBest;
[manager startUpdatingLocation];
然后将这些方法:
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
geolocerror = YES;
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
NSLog([NSString stringWithFormat:@"Lat: %.8f", currentLocation.coordinate.latitude]);
NSLog([NSString stringWithFormat:@"Long: %.8f", currentLocation.coordinate.longitude]);
}
}
不要忘记添加CoreLocation在你的框架中。
你可以请阅读问题。再次? –
@ iTroyd23在某些情况下,CLLocation可以返回没有Internet连接的结果。我需要在所有情况下都需要 –
。 –
看一看corelocation
的Core Location框架可以让你确定当前位置或 航向与设备相关联。该框架使用可用的硬件来确定用户的位置和标题。您可以在此框架中使用 类和协议来配置和安排位置和标题事件的传递。您还可以使用它来定义 地理区域,并监视用户何时穿越这些区域的边界。在iOS中,您还可以定义围绕蓝牙的区域信标
。
- 1. 获取本地IP地址而无需连接到互联网
- 2. 位置与关闭互联网连接
- 3. 使用iPhone GPS无需互联网更新用户位置
- 4. 获取用户的大致位置,没有GPS/WiFi /互联网
- 5. 如何在xcode中使用互联网获取当前位置?
- 6. Android - 让用户连接到互联网
- 7. 互联网连接
- 8. 以用户设置,如果没有互联网连接
- 9. Rmpi是否需要互联网连接?
- 10. Flowplayer需要互联网连接?
- 11. GCM是否需要互联网连接?
- 12. 如何获取android的互联网连接状态?
- 13. 直到连接到互联网才能获取当前位置 - Android GPS
- 14. Magento的API访问,而无需使用互联网连接
- 15. Android:使应用程序无需互联网连接
- 16. 直接连接到互联网而无需代理
- 17. 如何检查用户有互联网连接,使用angularJs
- 18. 客户端网页文本翻译(无互联网连接)
- 19. AVD无法连接到互联网
- 20. Eclipse无法连接到互联网
- 21. Netbeans无法连接到互联网
- 22. Android AVD无法连接到互联网
- 23. 如何确定Android互联网连接?
- 24. WinRT如何检查互联网连接?
- 25. 如何检查互联网连接?
- 26. 如何知道用户是否连接到互联网?
- 27. 如何检查用户是否与互联网连接
- 28. 如何在没有互联网连接时提醒用户
- 29. 如何检查用户是否连接到互联网wp7?
- 30. 获取互联网
只需发送用户短信,并告诉他回复当前的经纬度 –
请参阅:http://stackoverflow.com/questions/14326890/is-it-possible-to-use-core-location-gps-没有任何互联网连接disa – Ricky