Swift:手势识别器无法识别select器发送到实例
我试图在XCode中做一个手势识别器,这样我就可以点击我的MKMapView并执行一些操作。 不过,每当我长按地图,我都会收到“无法识别的select器发送到实例”。
这是我在viewDidLoad中的代码:
let gestureRecognizer = UILongPressGestureRecognizer(target: self, action: "handleTap:"); self.mapViewPlace.addGestureRecognizer(gestureRecognizer);
以后的function在这里:
func handleTap(gestureReconizer: UILongPressGestureRecognizer) { }
有任何想法吗?
请给Neo信用。 你需要改变你的语法:
let gestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleTap)
附注:对于Swift,你不需要用分号结束你的代码行。
- UIPickerViewselect指示器在iOS10中不可见
- GMSTileURLConstructor返回缩放的奇怪数据
- 如何将类的IBAction方法转换为另一个类
- 在ionic framework中显示连接错误消息
- iOS 4:我如何模拟A4打印机?
- 跟随手指的旋转动画,跟随圆的外部路径的uibutton
- 我需要调用UICollectionView的dequeueCell:从数据源的cellForPath:?
- Xcode 6.0.1命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc失败,退出代码1
- 有没有可用于iOS的数据绑定机制?