2011-10-14 27 views

回答

0

重构到ARC后,我得到了同样的东西。

首先我在viewDidLoad中有以下代码;

CLLocationManager *lm =[[CLLocationManager alloc] init]; 
lm.delegate = self; 
lm.desiredAccuracy = kCLLocationAccuracyBest; 
[lm startUpdatingLocation]; 

我做了在德headerfile以下

@interface ViewController : UIViewController <CLLocationManagerDelegate> 
{ 
CLLocationManager *locationManager; 
} 

@property(nonatomic, strong)CLLocationManager *locationManager; 

而且

@synthesize locationManager; 

的代码我在viewDidLoad中改变

locationManager =[[CLLocationManager alloc] init]; 
locationManager.delegate = self; 
locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
[locationManager startUpdatingLocation]; 
0

检查 “setUserTrackingMode:动画:” 和“userTrackingMode”。两者都是iOS5中的新功能。我有一个类似的问题,并通过在setUserTrackingMode函数中设置MKUserTrackingModeFollow来修复它。我认为默认跟踪模式是MKUserTrackingModeNone,只调用一次mapView:didUpdateUserLocation。

如果您的问题是从未调用过mapView:didUpdateUserLocation,那么请查看新xcode中的选项,在控制台输出下方有一个图标,如ipad中的gps图标,它可以让您模拟位置。

0

我知道这是一个古老的线程。无论如何,我会回答,也可能会帮助其他人。

我有类似的问题与iOS 6.我能够通过将mapview代理设置为self来解决。

像这样:

[mapView setDelegate:self]; 

确保您ViewController.h有MKMapViewDelegate沿线:

@interface ViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate>