如何在切换跟踪模式时旋转iOS MKMapView,使其朝北? [英] How to rotate iOS MKMapView so that it north-oriented when switching tracking mode?

查看:87
本文介绍了如何在切换跟踪模式时旋转iOS MKMapView,使其朝北?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iPad应用程序(iOS 5.1),并且使用MKMapView在应用程序中显示地图.

I am working on an iPad app (iOS 5.1), and I use MKMapView to display a map in my app.

我正在使用MKUserTrackingModeNone,MKUserTrackingModeFollow,MKUserTrackingModeFollowWithHeading在三种不同的地图方向模式之间进行切换,并且可以正常工作.

I am switching between the three different map orientation modes using MKUserTrackingModeNone, MKUserTrackingModeFollow, MKUserTrackingModeFollowWithHeading and this works.

但是,当我从MKUserTrackingModeFollowWithHeading切换到MKUserTrackingModeNone时,我无法将地图的方向重置为朝北的方向(地图的北部位于屏幕顶部).

However I have a problem with the orientation of the map not resetting to north-facing orientation (north on the map being at the top of the screen) when switching from MKUserTrackingModeFollowWithHeading to MKUserTrackingModeNone.

在ipad上的内置地图应用上,流程如下:

On the built-in maps app on the ipad, the flow is like this:

  1. 启动应用程序时,它处于MKUserTrackingModeNone模式,并且是朝北的
  2. 当您切换方向模式时,它将更改为MKUserTrackingModeFollow,并且方向仍为北.
  3. 再次切换时,它将更改为MKUserTrackingModeFollowWithHeading,并且地图将根据您面向iPad/iPad的方向旋转.
  4. 再次切换方向时,它会返回到MKUserTrackingModeNone,并且地图会很好地旋转回到北向.

我希望我的应用在切换模式时在方向方面表现出相同的方式,但是当我按照上述步骤4进行操作并从MKUserTrackingModeFollowWithHeading切换到MKUserTrackingModeNone 时,方向保持不变只是在进行方向切换之前,而不是旋转回北方向.

I would like my app to behave in the same way in regards to orientation when switching mode, but when I do as in step 4 above and switch from MKUserTrackingModeFollowWithHeading to MKUserTrackingModeNone, the orientation stays as it was just before making the orientation switch instead of rotating back to north orientation.

我正在使用放置在工具栏中的标准MKUserTrackingBarButtonItem控件进行方向切换.

I am making the orientation switch with the standard MKUserTrackingBarButtonItem control placed in a toolbar.

关于如何解决这个问题的任何想法?

Any ideas of how to solve this?

谢谢!

推荐答案

您是否正在使用标准的iOS按钮栏项来执行此操作?我的应用程序开始运行,并且一旦我将其从followWithHeading轻触到非,它便会旋转回北.

Are you using the standard iOS button bar item for doing this? My app does and as soon as I tap it from followWithHeading to non it rotates back to north is up.

这篇关于如何在切换跟踪模式时旋转iOS MKMapView,使其朝北?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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