2010-10-04 19 views

回答

6
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; 
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
cell.textLabel.text = "new text";
+0

如果这是一个自定义的UITableViewCell?我不相信这个代码的作品。我试过了,但名字保持不变。我在我的cellForRowAtIndexPath中这样做...行的值在一个int变量中。 – lab12 2010-10-04 01:18:12

+0

我更新了我的答案几次,所以你现在应该试试。在你的cellForRowAtIndexPath方法中你不需要这个;这就是细胞本身的创造。如果你想稍后改变它,你应该在其他地方使用这个代码。 – titaniumdecoy 2010-10-04 01:20:45

+0

至于自定义UITableViewCells,它取决于单元格的创建方式。如果它不使用textLabel属性来显示其文本,则必须查看其实现以确定如何更新其内容。 – titaniumdecoy 2010-10-04 01:44:42