【发布时间】:2014-08-09 08:45:56
【问题描述】:
我有一个带有 CustomCell 的 UITableView,每个单元格都有一个 UIButton,并且按钮在 cellForRowAtIndexPath 中获取标签
cell.ffButton.tag = indexPath.row;
[cell.ffButton addTarget:self action:@selector(changeTitle:) forControlEvents:UIControlEventTouchUpInside];
如果用户按下UIButton,我希望它只更改按钮标题。
changeTitle 操作在我的 UITableView.m 中,而不是在 CustomCell.m 文件中
用谷歌搜索我需要的东西,但找不到任何东西。
有什么想法吗? :)
更新:
我的表格视图
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"NotMutualCustomCell";
notMutualCustom *cell = (notMutualCustom *) [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.ffButton.hidden = NO;
cell.ffButton.tag = indexPath.row;
[cell.ffButton setTitle:@"Title" forState:UIControlStateNormal];
[cell.ffButton addTarget:self action:@selector(changeTitle:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
【问题讨论】:
标签: ios objective-c xcode uitableview ios7