4

当我的 iOS6MKMapView处于MKUserTrackingModeFollowWithHeadingorMKUserTrackingModeFollow时,缩放手势(捏合、双击、两指点击)有时会起作用,但并非总是如此。

该问题似乎发生在afterbeforedidUpdateUserLocation:调用时。 regionWillChangeAnimated regionDidChangeAnimated

有想法该怎么解决这个吗?

为了隔离问题,我创建了一个单视图应用程序,其中包含一个MKMapView和一个UIToolbar(在 .xib 中设置),我正在向其中添加一个MKUserTrackingBarButtonItem. UIViewController充当<MKMapViewDelegate>. _ 下面是完整的实现代码:

#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
4

0 回答 0