gpt4 book ai didi

ios - 如何检测 iOS 上 AnnotationView 的长压?

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

我想重现 iOS 仪表板在我的 map 注释上的效果,方法是在我长按其中一个时摇晃它们。然而,我一直坚持检测用户何时长按了一个按钮。这是代码:

override init(annotation:MKAnnotation, reuseIdentifier identifier:String) {
bookingImageView = UIImageView(image: self.bookingImage)
...
let lpgr = UILongPressGestureRecognizer(target: self, action: Selector("handleLongPressure:"))
lpgr.minimumPressDuration = 2.0; //user must press for 2 seconds
bookingImageView.addGestureRecognizer(lpgr)
}

func handleLongPressure(notification: NSNotification){
wobble()
}

如果我将手势关联到注释或其 subview(bookingImageView),它就不起作用。

最佳答案

您需要启用用户交互

bookingImageView.userInteractionEnabled = true

关于ios - 如何检测 iOS 上 AnnotationView 的长压?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31489449/

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