iOS 6 Map doesn't zoom with MKUserTrackingModeFollow

一曲冷凌霜 提交于 2019-12-07 11:13:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!