Ios UIGestureRecognitor不工作,导致应用程序运行缓慢
在地图视图中,我想确认,如果用户触摸地图中的任何位置,应用程序将停止更新位置。但似乎什么都没有发生,并且需要大约10-15秒才能在应用程序中执行操作(使应用程序非常缓慢和滞后)。我一直在使用以下代码:Ios UIGestureRecognitor不工作,导致应用程序运行缓慢,ios,swift,uinavigationcontroller,location,uigesturerecognizer,Ios,Swift,Uinavigationcontroller,Location,Uigesturerecognizer,在地图视图中,我想确认,如果用户触摸地图中的任何位置,应用程序将停止更新位置。但似乎什么都没有发生,并且需要大约10-15秒才能在应用程序中执行操作(使应用程序非常缓慢和滞后)。我一直在使用以下代码: @IBOutlet var Map: MKMapView! let locationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad()
@IBOutlet var Map: MKMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
StopUpdate.hidden = true
Longi.hidden = true
Lati.hidden = true
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.requestLocation()
locationManager.startUpdatingLocation()
locationManager.stopUpdatingLocation()
self.view.addGestureRecognizer(UIGestureRecognizer(target: self, action: "tapClose"))
}
func tapClose(gesture: UITapGestureRecognizer){
locationManager.stopUpdatingLocation()
StopUpdate.hidden = true
UpdateLocation.hidden = false
}
由于手势识别器,我的应用程序速度慢且滞后。有什么解决方案吗?添加UITap手势的正确方法
class DashVC: UIViewController, UIGestureRecognizerDelegate{
}
在viewdidload中按如下方式定义Tap手势
let tapDashBoard = UITapGestureRecognizer(target: self, action: #selector(DashVC.DashBoardTapped(_:)))
tapDashBoard.delegate = self
view.addGestureRecognizer(tapDashBoard)
和行动
func DashBoardTapped(sender: UITapGestureRecognizer? = nil) {
}
是否使用未解析的标识符“DashVC”?如何修复?这是ViewController的名称。替换为ViewController名称修复了这一问题,但im geting new无法将“ViewController”类型的值分配给tapDashBoard.delegate=selfIt work行中的“UIgestureRecognitizerDelegate”类型!它只需要鼠标右键就能工作吗?单击鼠标左键什么也不做。因为现在,当程序跟踪位置时,我不能放大/缩小或做任何其他事情,因为“当前位置”点始终位于中心