zhtway
zhtway

Reputation: 283

Want to fire IBAction on Touch up Inside of Static TableViewCells

I have a Static TableViewCells on a storyboard. There are just labels in those cells. I would like to fire IBAction event upon touch. What I am doing right now is create a full-size white button and linked to IBAction. But it doesn't show highlighted color when the cell is selected because cell is behind the button.

Upvotes: 3

Views: 3310

Answers (2)

melsam
melsam

Reputation: 4977

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

cell.selectionStyle = UITableViewCellSelectionStyleBlue;

Does this fix it?

Upvotes: -1

CodaFi
CodaFi

Reputation: 43330

UITableViewCells have a delegate method specifically for handling row touches -tableView:didSelectRowAtIndexPath:

If you need a custom button over each cell, subclass UITableViewCell instead of going through a storyboard. As much as they may be a timesaver, storyboards are really a limiting factor when it comes to nitty gritty iOS programming.

Upvotes: 3

Related Questions