设置MKUserTrackingModeFollowWithHeading [英] Setting MKUserTrackingModeFollowWithHeading

查看:484
本文介绍了设置MKUserTrackingModeFollowWithHeading的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在viewDidLoad方法(以及viewWillAppear)中设置用户跟踪模式。如果我将其设置为MKUserTrackingModeFollowWithHeading(值为2),则它不会生效。实际上,在将其值设置为2之后,如果我将其打印为值,则为1,为什么?我从未在任何编程经历中看到过这样的事情!

I tried to set the user tracking mode in the viewDidLoad method (and in viewWillAppear). If I set it to MKUserTrackingModeFollowWithHeading (value of 2), it does not take effect. Actually, right after setting its value to 2, if I print it value, it is 1, why? I have never seen such a thing in any programming experience!

以下是我如何设置它:

[self.mapView setUserTrackingMode: MKUserTrackingModeFollowWithHeading 
                         animated: YES];

如果我在viewWillAppear方法中执行相同操作,效果是相同的。但是,第二次显示此视图时,该设置将生效。 (我有一个制表视图控制器,我将视图切换到另一个,然后切换回来)。

If I do the same in the viewWillAppear method, the effect is the same. However, the second time this view is displayed, the setting will take effect. (I have a tab viewcontroller, I switch the view to another and then switch back).

我认为它没有生效的方式有两个措施:(1)在地图视图中设置它(2)后立即打印其值,不显示标题。

The way I see it does not take effect is two measures: (1) print its value right after setting it (2) in the map view, the heading is not displayed.

发生了什么事?

推荐答案

我知道这是一个非常古老的帖子,但为了防止其他人在那里寻找解决方案,原因是因为你需要设置userTrackingMode地图加载后。因此,将您的类设置为委托,然后添加此委托方法:

I know this is a really old post, but just in case it helps others out there looking for a solution, the reason is because you need to set the userTrackingMode after the map has loaded. So set your class as the delegate, then add this delegate method:

- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView {
    mapView.userTrackingMode = MKUserTrackingModeFollowWithHeading;
}

这篇关于设置MKUserTrackingModeFollowWithHeading的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆