【发布时间】:2015-02-25 17:42:58
【问题描述】:
从其他 viewcontoller 调用 loadData 方法,例如:
TestTVC *testTVC = [[TestTVC alloc] init];
[testTVC loadData];
我把NSLog(@"testTVC Array section:%lu has %lu rows ")放在numberOfRowsInSection中,它返回结果。
但是在 cellForRowAtIndexPath 部分,NSLog(@"cellForRowAtIndexPath") 从未以某种方式打印。
我确信我的委托和数据源设置正确。因为它在[self loadData]时有效
我也尝试在主线程中运行它,它不起作用。
有人知道吗?谢谢。
更新:我使用[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationNone]; 而不是[self.tableView reloaddata],它可以工作,但它没有重新加载表格单元格中的 UIImages。
NSLog(@"change cell image to testTVCImg1");
[testTVCCell.selectImgView setImage:[UIImage imageNamed:@"testTVCImg1"]];
打印了 NSLog 调试消息,但图像没有改变。
【问题讨论】:
-
您对
loadData的实现是什么?numberOfRowsInSection的结果是什么? -
插入 testTVC.delegate = self(或 testTVC);和 testTVC.datasource = self(或 testTVC);在 loadData 方法前面。
标签: ios objective-c uitableview