ibireme / YYKit

A collection of iOS components.
MIT License
13.99k stars 3.69k forks source link

YYLabel的highlightTapAction在swift点击的问题 #517

Open hqwsun opened 5 years ago

hqwsun commented 5 years ago

YYLabel如果是使用swift来写的话,通过调用highlightTapAction的点击事件点击是没办法响应的,需要两个手指同时按住才可以,这是为什么?

label.highlightTapAction = { [weak self](contentView, text, range, rect) in

            let url:String = text.attributedSubstring(from: range).string
            print(url)
}
ilei131 commented 5 years ago

检查页面是不是加了别的手势,需要将手势的cancelsTouchesInView和delaysTouchesBegan属性设置为false,例如: let tap = UITapGestureRecognizer.init(target: self, action: #selector(didTapTableView(_:))) tap.cancelsTouchesInView = false tap.delaysTouchesBegan = false self.tableView.addGestureRecognizer(tap)