【发布时间】:2014-03-20 16:07:27
【问题描述】:
我一直在尝试为一些我认为不应该那么困难的事情找到一个简单的答案,但我要么找不到合适的答案,要么无法理解它。
我正在尝试更改/编辑一个特定表格视图单元格的文本标签内容。因此,为了举例,我希望在 UITableView 之外但在同一个视图控制器中使用 UIButton 来更改第 2 行中的文本,同时保持其他文本相同。
我知道您使用viewWithTag,但除此之外我无法弄清楚!请帮忙....
这是我目前的代码
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
EntryCell *cell = (EntryCell *)[contentTable dequeueReusableCellWithIdentifier:@"Cell"];
cell.mainLabel.tag = indexPath.row;
cell.mainLabel.text = @"hello";
return cell;
}
-(void)buttonPressed:(UIButton *)button {
cell.mainLabel = (UILabel *)[contentTable viewWithTag:2];
cell.mainLabel.text = @"goodbye";
}
【问题讨论】:
标签: ios objective-c uitableview tags