myButton1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton1.frame = CGRectMake(0, 20, 80, 30); // position in the parent view and set the size of the button
[myButton1 setTitle:@"MAIL!" forState:UIControlStateNormal];
// add targets and actions
[myButton1 addTarget:self action:@selector(buttonClicked1:) forControlEvents:UIControlEventTouchUpInside];
// add to a view
//[self addSubview:myButton];
myButton1.tag=jk;//indexPath.row;
//[self.view addSubview:myButton];
[cell.contentView addSubview:myButton1];
/// ADDING METHOD TO THOS BUTTONS
- (IBAction)buttonWasPressed:(id)sender
{
NSIndexPath *indexPath =
[self.myTableView
indexPathForCell:(UITableViewCell *)[[sender superview] superview]];
NSUInteger row = indexPath.row;
// Do something with row index
}
1 comment:
Thanks!
Post a Comment