在我的代码中,我有以下说法:
@objc func handleTap(_ gestureRecognizer: UILongPressGestureRecognizer) {
let location = gestureRecognizer.location(in: mapView)
locCoord = mapView.convert(location, toCoordinateFrom: mapView)
let annotation = MKPointAnnotation()
annotation.coordinate = locCoord!
annotation.title = "latitude:" + String(format: "%0.02f", annotation.coordinate.latitude) + "& longitude:" + String(format: "%0.02f", annotation.coordinate.longitude)
annotation.subtitle = "Loc of new bball court"
mapView.addAnnotation(annotation)
performSegue(withIdentifier: "addCourtSegue", sender: UILongPressGestureRecognizer.self)
}
func prepare(for segue: UIStoryboardSegue, sender: UILongPressGestureRecognizer) {
super.prepare(for: segue, sender: sender)
let vc = segue.destination as! Newcourtviewcontroller
vc.locCoord = self.locCoord
}
基本上,我在屏幕上设置了一个MapKit,在MapKit的顶部有一个手势识别器。每当用户点击地图上的位置时,它都会创建注释并执行segue以转到另一个屏幕(此segue是从情节提要中的一个视图控制器设置到下一个视图控制器的,并提供了我引用的标识标签)在performSegue中)。但是,当我打开iOS模拟器并尝试使用segue时,它将在两个屏幕之间切换(中间屏幕仅显示0.5-1秒),而只应切换到一个屏幕。看下面的图片。我可以确定为什么要这样做,因为我只在情节提要中设置了segue才能过渡到一个屏幕。任何帮助将不胜感激。
Second screen segue transitions to First/intermediate screen segue transitions to