【发布时间】:2015-05-05 16:53:59
【问题描述】:
我怎样才能将UITapGestureRecognizer 添加到 UITextView 但仍然让UITextView 的触摸正常?
目前,只要我向我的 textView 添加自定义手势,它就会阻止点击 UITextView 默认操作,例如定位光标。
var tapTerm:UITapGestureRecognizer = UITapGestureRecognizer()
override func viewDidLoad() {
tapTerm = UITapGestureRecognizer(target: self, action: "tapTextView:")
textView.addGestureRecognizer(tapTerm)
}
func tapTextView(sender:UITapGestureRecognizer) {
println("tapped term – but blocking the tap for textView :-/")
…
}
如何在处理点击的同时保持光标定位等任何 textView 行为不变?
【问题讨论】:
-
您是否尝试将
cancelsTouchesInView设置为false? -
当你想移动光标时你会怎么做?
标签: ios swift uitextview uitapgesturerecognizer