(使用 Xcode 6)
我的跟踪按钮在导航栏的右侧,它不会触发该方法,我不知道为什么,这应该是正确的方法。
按钮本身是有功能的。
- (void)viewDidLoad
{
[super viewDidLoad];
//location initial settings:
firstLaunch = YES;
self.mapView.delegate = self;
[self.mapView setShowsUserLocation:YES];
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
currentCentre = self.mapView.centerCoordinate;
//create a thread queue
[self queryGooglePlaces: currentCentre];
//navBar:
MKUserTrackingBarButtonItem *trackButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView:_mapView];
[trackButton setTarget:self];
[trackButton setActionselector(track];
self.navigationItem.rightBarButtonItem = trackButton;
}
-(void) track: (id) sender {
NSLog(@"clicked !");
}
Best Answer-推荐答案 strong>
我认为您不能以这种方式使用 MKUserTrackingBarButtonItem ——它已经有一个目标(关联的 map View )和一个 Action (更改跟踪模式)。相反,我会查看 -[MKMapViewDelegate mapView:didChangeUserTrackingMode:animated:] 以在单击按钮时响应 map 模式更改。
关于ios - 向 MKUserTrackingBarButtonItem 添加一个 Action ,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/24391731/
|