我有一个Swift中的UITextView:
let contactText = UITextView(frame: CGRectMake(0,0,200,50))
contactText.selectable = true
contactText.dataDetectorTypes = UIDataDetectorTypes.Link
contactText.userInteractionEnabled = true
contactText.editable = false
contactText.text = "Some text goes here and some website here www.google.com"
self.view.addSubview(contactText)
我希望能够双击或长按选择文本,然后给用户选择全部或复制的选项(就像大多数应用程序一样)。尽管上面的代码似乎应该可以工作,但它并没有起作用,还有其他的方法吗?
编辑:
实际上,上面的代码是有效的,为什么它不起作用(还不确定),可能是因为UITextView在一个带有PanGestureRecognizer的UIView中,所以可能被阻止了?有什么想法吗?
gestureRecognizer:shouldRequireFailureOfGestureRecognizer:
https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIGestureRecognizerDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIGestureRecognizerDelegate/gestureRecognizer:shouldRequireFailureOfGestureRecognizer: - Lyndsey Scott