gpt4 book ai didi

ios - regiondidchange 在 app load swift 上多次调用

转载 作者:行者123 更新时间:2023-11-28 11:13:49 25 4
gpt4 key购买 nike

我有一张 map ,当我平移或输入一个位置并导航到它时,我希望运行一个简单的打印功能。然而,我已经完成了这个,当我第一次加载应用程序时,它会多次调用该打印函数,直到它完成放大。有没有办法不计算应用程序加载区域变化的初始值?

最佳答案

终于在这里找到答案http://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
}
}

关于ios - regiondidchange 在 app load swift 上多次调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33131213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com