tags:

views:

157

answers:

1

Hi! I m adding UIButton on each cell of UITableView dynamically. I want to handle touch event on this UIButton. Can u plz help me to sort out this issue?

Thanks In Advance, Vikas

+1  A: 
[myCellButton addTarget:self action:@selector(myCellButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
Alex Reynolds
I have added this statement in didSelectRowAtIndexPath method of UITableView but when I touch on Button its not going in didSelectRowAtIndexPath. If I touch cell/row of UITableView outside of button it goes inside didSelectRowAtIndexPath. I m not getting why this is happening?.......How to resolve this?
vikas Savardekar
You would add this target just after the `UIButton` is created, then add the button to the cell when the cell is initialized. The `didSelectRowAtIndexPath` method is for responding to tapping the the cell (row) itself, not the button. This target action is for the button itself. Is this clearer?
Alex Reynolds
I want to create UIButton on each cell of UITabelView and when I click on that UIButton it should change image on UIButton. So where to create UIButton for each cell
vikas Savardekar