限制 iPad 上的 Mapkit 区域
我需要一个 iPad 应用程序使用 Mapkit 显示给定的国家/地区以及一些注释。是否可以对其进行限制,以便用户无法滚动到我想要显示的区域之外的另一个区域? 例如,我的应用程序想要显示有关巴西的内容,我可以让用户无法离开该国家吗?
这个问题是关于Mapkit的,我知道我可以有一个有问题的国家的图像,并尝试获得与谷歌地图类似的效果......
谢谢!
I need to have an iPad app show a given country with some anotations using mapkit. Is it possible to limit it so the user can not scroll over to another region than the one i want to show?
For example, my app wants to show stuff about Brazil, can i make it so the user can not move away from that country?
This question is regarding Mapkit, i know i could have an image of the country at question and try to get a similar effect to google map's...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这是否有效,因为我从未尝试过,但我认为可能会。
首先对 MKMapView 进行子类化。然后,覆盖所有触摸处理程序(例如,touchesBegan:withEvent:、touchesEnded:withEvent: 等)。在重写的触摸处理程序中,对地图视图上显示的当前区域进行边界检查。如果它位于(或者可能非常接近)您想要显示的区域的边缘,则不要对触摸事件执行任何操作。否则,只需将触摸事件传递给该方法的超类实现。
如果这有效,请告诉我。
I don't know if this will work as I have never tried it, but I think it might.
Start by subclassing the MKMapView. Then, override all the touch handlers (e.g. touchesBegan:withEvent:, touchesEnded:withEvent:, etc...). In the overridden touch handlers do a bounds check on the current region being displayed on the mapview. If it is at (or maybe really close) to the edge of the area you want to show, then don't do anything with the touch event. Otherwise, just pass the touch event to the super classes implementation of the method.
If this works, let me know.