【发布时间】:2014-01-17 20:44:45
【问题描述】:
我有一个带有 UITableCells 的 UITable,如下所示:
[我的标签我的按钮]
[我的标签我的按钮]
[我的标签我的按钮]
[我的标签我的按钮]
我希望我的 handlerCellButtonClicked 也能获得对单元格索引的引用。当按钮被触摸时,我怎样才能获得对这个索引的引用?
/** called by table to get the cell needed by the index */
-(UITableViewCell*)tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
...
//init cell
...
//configure the cells custom button handlers
[cell.myButton addTarget:self action:@selector(handlerCellButtonClicked) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
/** handler when the button in the cell is clicked */
- (void)handlerCellButtonClicked{
NSLog(@"cell myButton clicked");
}
【问题讨论】:
标签: iphone objective-c