ios7 – MKMapView禁用旋转

前端之家收集整理的这篇文章主要介绍了ios7 – MKMapView禁用旋转前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用MKMapView作为主要显示区域的应用程序.这应始终朝北向上.但是快速无意的滑动并且它会旋转,导致指南针出现.

有没有办法阻止这种情况发生并保持视图锁定在北方?我在这里看到了一些提示,但没有任何内容涉及任何类型的内置机制.

解决方法

快速浏览Apple关于MKMapView的文档:

rotateEnabled A Boolean value indicating whether the map camera’s
heading information is used.

@property(nonatomic,getter=isRotateEnabled) BOOL rotateEnabled
Discussion When this property is set to YES and a valid camera is
associated with the map,the camera’s heading angle is used to rotate
the plane of the map around its center point. When this property is
set to NO,the camera’s heading angle is ignored and the map is always
oriented so that true north is situated at the top of the map view.

因此,您可以尝试将mapview rotateEnabled属性设置为’NO’.

Apple MKMapView reference

猜你在找的iOS相关文章