我試圖點擊手勢添加標籤[的UILabel]的出口集合,像這樣:我們如何將UIGestureRecognizer添加到Outlet Collection?
@IBOutlet var subLabels: [UILabel]!
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(HomePageViewController.selectSubLabel(tap:)))
tap.numberOfTapsRequired = 1
tap.cancelsTouchesInView = false
for i in (0..<(subLabels.count)) {
subLabels[i].addGestureRecognizer(tap)
}
}
func selectSubLabel(tap: UITapGestureRecognizer) {
print("Gesture Is WORKING!")
}
,我試圖將其添加在故事板單個標籤上;但NONE正在工作。