While my iOS6 MKMapView
is in MKUserTrackingModeFollowWithHeading
or MKUserTrackingModeFollow
, zoom gestures (pinch, double-tap, two-finger tap) work sometimes, but not always.
The issue seems to occur when didUpdateUserLocation:
is called after regionWillChangeAnimated
and before regionDidChangeAnimated
.
Any ideas on how to fix this?
To isolate the problems, I've created a Single View Application with an MKMapView
and a UIToolbar
(set up in a .xib), to which I'm adding a MKUserTrackingBarButtonItem
. The UIViewController
acts as a <MKMapViewDelegate>
. Here's the complete implementation code:
#import "ViewController.h"
@implementation ViewController
@synthesize mapView, toolbar;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.mapView setDelegate:self];
MKUserTrackingBarButtonItem *trackButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.mapView];
[toolbar setItems:[NSArray arrayWithObjects:trackButton, nil] animated:YES];
}
#pragma mark - MKMapViewDelegate
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated {
NSLog(@"regionWillChange >>");
}
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
NSLog(@"<< regionDidChange");
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
NSLog(@"-- didUpdateUserLocation --");
}
- (void)mapView:(MKMapView *)mapView didChangeUserTrackingMode:(MKUserTrackingMode)mode animated:(BOOL)animated {
// required for <MKMapViewDelegate>
}
#pragma mark - etc
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
来源:https://stackoverflow.com/questions/15665127/ios-6-map-doesnt-zoom-with-mkusertrackingmodefollow