【发布时间】:2018-09-25 08:58:27
【问题描述】:
Swift 4 iOS 11
尝试使用此代码向标签添加手势,它会触发,但会因无法识别的选择器而崩溃。
尝试使用和不使用@objc,也尝试使用@selector(ViewController.copyURL),尝试打开isUserInteractiveEnabled = true;没有工作
@IBOutlet weak var zeroURL: UILabel!
let press = UILongPressGestureRecognizer(target: zeroURL, action: #selector(copyURL))
view.addGestureRecognizer(press)
@objc func copyURL() {
UIPasteboard.general.string = self.zeroURL.text
print("copied")
zeroURL.alpha = 0
UIView.animate(withDuration: 0.75, delay: 0.25, options: [.curveEaseOut], animations: {
self.zeroURL.alpha = 1.0
}) { (status) in
// do nothing
}
}
【问题讨论】:
-
你的
zeroURL是什么?
标签: ios swift uilabel uigesturerecognizer unrecognized-selector