可以幫助我嗎?我需要停止MkMapView方法setRegion:region animated:true。我需要使用選項設置新區域以停止它。 謝謝。MKMapView setRegion如何停止動畫
1
A
回答
-1
最簡單的方法是nil
MKMapView
的委託,以便在它之後不會調用委託方法。
self.mapView.delegate = nil;
0
有一兩件事你可以嘗試創造一個CADisplayLink
被拴在屏幕刷新頻率,然後在其回調,檢查地圖的當前狀態。在那裏您可以調用另一個setRegion:animated:
到當前位置以停止以前的動畫。
2
如果您創建另一個動畫,但是與現有區域不同的區域,則會使現有動畫失效。注意:如果我嘗試創建一個新的動畫,但是對於visibleMapRect,iOS將會忽略它。
func stopZoom() {
//the trick: creating a region very similar to the existing one
var mapRegion:MKCoordinateRegion = MKCoordinateRegionForMapRect(self.mapView.visibleMapRect)
mapRegion.span.latitudeDelta = mapRegion.span.latitudeDelta + 0.000001
UIView.animateWithDuration(0.1, delay: 0.0, options: [], animations: {
let mapRegion:MKCoordinateRegion = mapRegion
self.mapView.setRegion(mapRegion, animated: true) //this will invalidate the other animations
}) { (completed: Bool) -> Void in
}
}
,以供參考startZoom方法:
func startZoom() {
UIView.animateWithDuration(10, delay: 0.0, options: [UIViewAnimationOptions.CurveLinear, UIViewAnimationOptions.AllowUserInteraction, UIViewAnimationOptions.BeginFromCurrentState], animations: {
let mapRegion:MKCoordinateRegion = MKCoordinateRegionMakeWithDistance(self.coordinate, 500, 500)
self.mapView.setRegion(mapRegion, animated: true)
}) { (completed: Bool) -> Void in
}
}
花相當多的時間來弄清楚這一點,我希望這將是對你有所幫助。
相關問題
- 1. 的MKMapView setRegion動畫防止在註釋視圖
- 2. MKMapView setRegion not exact
- 3. MKMapView崩潰setRegion
- 4. MKMapView的setRegion速度
- 5. 如何停止在mkmapview中滾動?
- 6. MKMapView和setRegion:動畫:不更新地圖視覺
- 7. 的MKMapView setRegion不恆定
- 8. 如何停止動畫
- 9. 如何停止動畫
- 10. 如何停止svg動畫?
- 11. 如何停止CSS動畫
- 12. 如何停止動畫?
- 13. 如何停止動畫WPF?
- 14. 如何停止動畫
- 15. 如何停止此動畫?
- 16. 如何停止動畫onBackPressed?
- 17. 如何停止滾動動畫
- 18. 懸停時動畫「停止」
- 19. 停止GIF動畫
- 20. android - 停止動畫
- 21. jQuery停止動畫
- 22. 如何停止ListView的PullToRefresh動畫
- 23. QML如何停止過渡動畫?
- 24. 如何在GameQuery中停止動畫
- 25. iphone:如何停止快門動畫?
- 26. 如何停止jQuery循環動畫?
- 27. 如何停止圖像動畫?
- 28. 如何使用beginAnimations後停止動畫?
- 29. 如何在C#/ WPF中停止動畫?
- 30. 如何停止滾動畫廊?