mapView.setRegion 动画的 Swift 完成处理程序?

标签 swift animation completionhandler

我正在尝试弄清楚如何判断以下动画何时完成:

self.mapView.setRegion(MKCoordinateRegionForMapRect(mapRect), 动画: true)

看起来 setRegion 不像其他命令那样支持完成处理程序。

我知道如何使用类似这样的东西创建一个通用的完成处理程序: How could I create a function with a completion handler in Swift?

但我不知道要检查什么变量来验证动画是否已完成。

最佳答案

您可以实现MKMapViewDelegate protocol以此目的。来自文档:

Because many map operations require the MKMapView class to load data asynchronously, the map view calls these methods to notify your application when specific operations complete.

这个方法应该做你想做的:

optional func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool)

Tells the delegate that the region displayed by the map view just changed.

关于mapView.setRegion 动画的 Swift 完成处理程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48800111/

相关文章:

ios - 在 SceneKit 中,当从 RunAction 的完成处理程序调用时,SCNAction 挂起

ios - prepareForSegue 不会在 Swift 4 中传递数据

ios - 在 Swift 中使用属性和 Map 过滤自定义对象数组

ios - 如何监听通知授权状态的变化

Javascript 翻转动画错误

java - Jpanel 和 Jframe 的重绘方法有何不同?

swift - 在下一个 UI View 出现之前获取用户身份验证

java - 在类中实现委托(delegate)(iOS/Swift)

javascript - Jquery 动画背景图像过渡

ios - AutoRenewable采购中的完成处理程序崩溃