我在自定义单元格内有一个UIButton,我想在用户按下该按钮时触发一个动作,但是我需要知道UIButton从哪一行被按下。将参数传递给选择器
这里是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
[self configureCell:cell atIndexPath:indexPath];
return cell;
...
[button addTarget:self action:@selector(buttonPressedAction:)forControlEvents:UIControlEventTouchUpInside];
}
- (void)buttonPressedAction:(UIButton *)button
{
//int row = indexPath.row;
//NSLog(@"ROW: %i",row);
}
如何通过indexPath作为参数传递给我的选择?
http://stackoverflow.com/questions/7504421/getting-row-of-uitableview-cell-on-button-press/7505025#7505025 – user523234