【发布时间】:2013-03-17 20:14:37
【问题描述】:
我正在尝试解决 iOS 6 中 MKUserTrackingModeFollowWithHeading 的两个问题:
MKUserTrackingModeFollowWithHeading工作短暂,但它很紧张,几乎立即返回到MKUserTrackingModeFollow,尤其是在高缩放级别时。重复更改
MKUserTrackingMode时,应用程序偶尔会崩溃:我在主线程上得到EXC_BAD_ACCESS,没有更多信息。这很难重现,但它已经反复发生。
对可能导致这种情况的任何想法?这感觉像是一个错误,但苹果自己的“地图”应用程序没有表现出这种行为。
为了隔离问题,我创建了一个带有MKMapView 和UIToolbar(在.xib 中设置)的单视图应用程序,我将向其中添加MKUserTrackingBarButtonItem。 UIViewController 充当<MKMapViewDelegate>。下面是完整的实现代码:
#import "ViewController.h"
@implementation ViewController
@synthesize mapView, toolbar;
- (void)viewDidLoad
{
[super viewDidLoad];
// Add MKUserTrackingBarButtonItem to toolbar
MKUserTrackingBarButtonItem *trackButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.mapView];
[toolbar setItems:[NSArray arrayWithObjects:trackButton, nil] animated:YES];
}
- (void)mapView:(MKMapView *)mapView didChangeUserTrackingMode:(MKUserTrackingMode)mode animated:(BOOL)animated
{
// Log MKUserTrackingMode change
NSString *modeType = (mode == 0) ? @"None" : ((mode == 1) ? @"Follow" : @"FollowWithHeading");
NSLog(@"MKUserTrackingMode changed to: %@", modeType);
}
@end
【问题讨论】:
-
此问题可能与我遇到的其他 MapKit 问题有关,也可能无关:iOS 6 Map doesn't zoom with MKUserTrackingModeFollow
-
我遇到了同样的问题。您是否偶然找到了解决方法?
-
@Jochen 我还没有找到解决方法或解决方案。在我的应用中,我最终禁用了 MKUserTrackingModeFollowWithHeading。
-
在 iPhone 4 iOS 6.0.1 上看到同样的问题
标签: ios iphone mkmapview mapkit core-location