我在自定義單元格內有一個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