例如。在cellForRowAtIndexPath中
cell.imageView.image = [UIImage imageNamed:@"checking.png"];
cell.textLabel.text = @"NAME";
cell.detailTextLabel.text = @"Checking...";如何从另一个函数更新imageView.image和detailTextLabel.text。有没有UITableView方法?我猜我需要使用IndexPath行来定位单元格。也许可以为每个imageView和detailTextLabel分配标签?
谢谢。
发布于 2013-05-14 23:56:27
更好的选择是更新模型中的数据,然后请求表视图执行reloadData (或者,如果您明确知道哪些行被更新,则使用reloadRowsAtIndexPaths:withRowAnimation:)。
这将维护数据模型的完整性,并且是管理视图的最简单代码。
发布于 2013-05-15 00:10:26
您应该尝试使用如下属性:
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) NSString *textLabel;
@property (nonatomic, strong) NSString *detailTextLabel;然后,将此属性添加到您的单元格中:
cell.imageView.image = image;
cell.textLabel.text = textLabel;
cell.detailTextLabel.text = detailTextLabel;每当更新数据时,都会调用重新加载单元格的方法(使用包含要重新加载的单元格的indexPath的数组):
[self.tableView reloadRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationNone];https://stackoverflow.com/questions/16547593
复制相似问题