0

我在 iOS7 中遇到了 MKMapView 的问题,我一直在 iOS5 上使用它并且工作完美(至少我试图做的)。

好吧,我的问题是 .userTrackingMode 在 iOS7 中不起作用。一直在寻找答案,但没有找到任何答案。

我想显示用户位置,它适用于 .showsUserLocation。但是当我想跟踪它时,它就像忽略它一样。有人有解决办法吗?

这就是我在 iOS 5 中的编写方式:

mMapView.showsUserLocation = YES;

mMapView.userTrackingMode = YES;

mMapView.userInteractionEnabled = NO;

而且我知道升级中的代码没有任何变化。

编辑:

不知道为什么,但我使用了 [self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES]; 在每次位置更改时更改标签的方法中。然后它的工作。

不知道为什么当我在 viewDidLoad... 中声明它时它不起作用?

4

1 回答 1

1

Welp,在 Apple 的 MKMapView 文档中,“ .userTrackingMode不是 BOOL,而是“ enum”(整数)属性:

typedef enum : NSInteger {
   MKUserTrackingModeNone = 0,
   MKUserTrackingModeFollow,
   MKUserTrackingModeFollowWithHeading,
} MKUserTrackingMode;

也许您设置错误可能是问题的一部分?

此外,设置它的最佳方法是通过此 API:

- (void)setUserTrackingMode:(MKUserTrackingMode)mode animated:(BOOL)animated(我已经为您链接了 Apple 文档)。那里有一个有用的 " animated" 论点。

于 2013-11-25T08:38:07.387 回答