called loadData method from other viewcontoller like:
TestTVC *testTVC = [[TestTVC alloc] init];
[testTVC loadData];
I put NSLog(@"testTVC Array section:%lu has %lu rows ")
in numberOfRowsInSection, it return result.
However in the cellForRowAtIndexPath section, the NSLog(@"cellForRowAtIndexPath")
never printed for somehow.
I was sure that my delegate and data source were set properly. Because it works when [self loadData]
I also try run it in the main thread, it does't work.
Does anyone knows? Thanks.
updated: i used [self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationNone];
instead of [self.tableView reloaddata]
, it works but it didn't reload the UIImages in table cell.
NSLog(@"change cell image to testTVCImg1");
[testTVCCell.selectImgView setImage:[UIImage imageNamed:@"testTVCImg1"]];
the NSLog debug message printed, but the image didn't changed.
cellForRowAtIndexPath
is called when a cell become visible.
When you do
TestTVC *testTVC = [[TestTVC alloc] init];
[testTVC loadData];
testTVC is not in the view hierarchy and its tableview neither. So cellForRowAtIndexPath
won't be call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.