I added some items to list and called [tableView reloadData];
The tableView position is changed. What is problem?
---- added ----
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if([dataCenter.newsList count] > 0){
return [dataCenter.newsList count];
}
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if((((indexPath.row + 1) - 5) % 10) == 0 && indexPath.row >= 4){
return 150;
}
else if(((indexPath.row + 1) % 5) == 0){
return 95;
}
return 90;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NewsInTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NewsInTableViewCell"];
return cell;
}
- (void) scrollViewDidScroll:(UIScrollView *)sender {
if(_tableNews.contentOffset.y + _tableNews.frame.size.height == _tableNews.contentSize.height){
[self requestDataByPage:(int)[dataCenter.newsList count]];
}
}
This is reloadData after calling and adding data.
- (void) requestDataByPage:(int)start{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
------calling data and adding-----
dispatch_async(dispatch_get_main_queue(), ^{
[_tableNews reloadData];
});
});
}
Please add Autolayout constraints on reloading the tableview on main thread .
dispatch.async.main{
self.tableview.reloadData() }
call: self.tableView.reloadData()
without [].
If this doesn't solve your problem, give us a bit example code of your project please.
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.