cow*_*boo 1 iphone gps core-location cllocationmanager ios
这是一些简单的代码:
// ViewControllerA.m
-(void) viewDidLoad
{
[super viewDidLoad];
self.networkMonitor = [[NetworkMonitor alloc] init];
...
[self.networkMonitor.locationManager startUpdatingLocation];
...
}
Run Code Online (Sandbox Code Playgroud)
在网络监视器中:
// NetworkMonitor.m
-(id) init
{
self = [super init];
if (self != nil) {
self.locationManager = [[CLLocationManager alloc] init];
[self.locationManager setDelegate:self];
}
return self;
}
...
// this is never called!
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"%s, location manager returned a new location.", __FUNCTION__);
...
}
// and neither is this
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSLog(@"Error: %@", [error description]);
}
Run Code Online (Sandbox Code Playgroud)
我调用了startUpdatingLocation,NetworkMonitor实现了CLLocationManagerDelegate ...为什么我没有调用didUpdateLocations?我应该误解这种方法吗?我假设一旦startUpdatingLocation被调用,我应该至少接到一个调用didUpdateLocations...我只是想获取用户的当前位置(不使用地图).任何想法或想法将不胜感激.
你在为ios6建造吗?来自docs:在iOS 5及更早版本中,位置管理器调用locationManager:didUpdateToLocation:fromLocation:方法.
| 归档时间: |
|
| 查看次数: |
2518 次 |
| 最近记录: |