我在桌面视图中有一个书签按钮:


出于某种原因,它对触碰没有反应。我有一个普通的IBOutlet,它有一个从未调用过的print语句。但是,当我点击书签时,单元格的作用并不像单击它一样。但是,当我点击书签时,单元格并不像单击了它一样。因此,在我看来,系统似乎知道按钮应该接收抽头(而不是单元格),但是IBOutlet不工作。有什么想法吗?该按钮及其超级视图都启用了用户交互。
发布于 2018-02-12 08:14:50
在cellForRowAtIndexPath()方法中将目标添加到Bookmark按钮中,并在单击Bookmark按钮forExample时执行您想做的任何操作:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cellReuseIdentifier")
cell.Bookmark.addTarget(self, action: #selector(tapBookMark(_:)), for: .touchUpInside)
return cell
}
func tapBookMark(_ sender: UIButton) {
print('bookMark tapped')
}https://stackoverflow.com/questions/48738992
复制相似问题