2015-10-14 45 views
0

我有一個地圖,當我平移或輸入一個位置並導航到它時,我想要一個簡單的打印功能運行。然而,我有這個成就,當我第一次加載應用程序它調用該打印功能幾次,直到它完成放大。有沒有辦法不計算初始應用程序加載區域更改?regiondidchange多次調用應用程序加載swift

+0

香港專業教育學院試圖FUNC mapViewDidFinishLoadingMap(MapView類:的MKMapView){ FUNC MapView類(MapView類:的MKMapView,regionDidChangeAnimated動畫:BOOL){ 流浪漢() }} – RubberDucky4444

+0

這FUNC mapViewDidFinishRenderingMap(MapView類:的MKMapView,fullyRendered:BOOL){ FUNC MapView類(MapView類:的MKMapView,regionDidChangeAnimated動畫:BOOL){ 流浪漢() }} – RubberDucky4444

回答

2

答案終於找到herehttp://ask.ttwait.com/que/5556977

private var mapChangedFromUserInteraction = false 

private func mapViewRegionDidChangeFromUserInteraction() -> Bool { 
let view = self.mapView.subviews[0] 
// Look through gesture recognizers to determine whether this region change is from user interaction 
if let gestureRecognizers = view.gestureRecognizers { 
    for recognizer in gestureRecognizers { 
     if(recognizer.state == UIGestureRecognizerState.Began || recognizer.state == UIGestureRecognizerState.Ended) { 
      return true 
     } 
    } 
} 
return false 
} 

func mapView(mapView: MKMapView, regionWillChangeAnimated animated:  
Bool) { 
mapChangedFromUserInteraction = 
mapViewRegionDidChangeFromUserInteraction() 
if (mapChangedFromUserInteraction) { 
    // user changed map region 
} 
} 

func mapView(mapView: MKMapView, regionDidChangeAnimated animated: 
Bool) { 
if (mapChangedFromUserInteraction) { 
    // user changed map region 
} 
} 
相關問題