I have a UITableView
with 5 UITableViewCells
. Each cell contains a UIButton
which is set up as follows:
- (UITableView
Though I like the tag way... if you don't want to use tags for whatever reason,
you could create a member NSArray
of premade buttons:
NSArray* buttons ;
then create those buttons before rendering the tableView and push them into the array.
Then inside of the tableView:cellForRowAtIndexPath:
function you can do:
UIButton* button = [buttons objectAtIndex:[indexPath row] ] ;
[cell.contentView addSubview:button];
Then in the buttonPressedAction:
function, you can do
- (void)buttonPressedAction:(id)sender {
UIButton* button = (UIButton*)sender ;
int row = [buttons indexOfObject:button] ;
// Do magic
}