3

我在情节提要上有一个静态 TableViewCells。这些单元格中只有标签。我想在触摸时触发 IBAction 事件。我现在正在做的是创建一个全尺寸的白色按钮并链接到 IBAction。But it doesn't show highlighted color when the cell is selected because cell is behind the button.

4

2 回答 2

3

UITableViewCells 有一个专门用于处理行触摸的委托方法-tableView:didSelectRowAtIndexPath:

如果您需要每个单元格上的自定义按钮,请子类化 UITableViewCell 而不是通过故事板。尽管故事板可能会节省时间,但在涉及到细节的 iOS 编程时,故事板确实是一个限制因素。

于 2012-05-19T04:39:28.787 回答
-1

Try adding this in your cellForRowAtIndexPath (when you initialize each cell):

cell.selectionStyle = UITableViewCellSelectionStyleBlue;

Does this fix it?

于 2012-05-19T06:04:53.363 回答