问题描述
我正在尝试找出如何确定何时完成以下动画的操作:
I'm trying to figure out how to tell when the animation is finished for the following:
self.mapView.setRegion(MKCoordinateRegionForMapRect (mapRect),动画:true)
它看起来不像 setRegion
支持像其他命令一样的完成处理程序。
It doesn't look like setRegion
supports a completion handler like other commands.
我知道如何使用类似这样的方式创建通用完成处理程序:
I know how to create a generic completion handler using something like this:How could I create a function with a completion handler in Swift?
但是我不知道要检查哪个变量以验证动画是否完成。
But I don't know what variable to check to verify the animation has completed.
推荐答案
您可以实现 MKMapViewDelegate
。从文档中:
You can implement the MKMapViewDelegate
protocol for this purpose. From the docs:
此方法应该可以满足您的要求:
This method should do what you want:
optional func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool)
这篇关于用于MapView.setRegion动画的Swift完成处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!