I have an UITableView
with Autolayout
in my app.
I need insert some rows to my TableView after press LoadEarlier
Button to index[0],
but i want to stay on my last position of my TableView.(Load Earlier Like WhatsApp & ...).
My problem is after setting contentOffset
the posion of my TableVoew isn't correct.
i check this link but this the problem isn't like my problem but i think the answer help us. UITableViewAutomaticDimension - Cells move when table is reloaded and this link : Keep uitableview static when inserting rows at the top
i do Like this :
// in ViewDidLoad
self.myTableView.estimatedRowHeight = 100;
self.myTableView.rowHeight = UITableViewAutomaticDimension;
//implemention of LoadEalier Method
CGFloat oldTableViewHeight = self.myTableView.contentSize.height;
for (int i = temp ; i < temp +26; i++) {
myObject * tempObject = [[myObject alloc]init];
tempObject.name = [NSString stringWithFormat:@"Obj : %d",i];
tempObject.uID = [[NSUUID UUID]UUIDString];
[_dataArray insertObject:tempObject atIndex:0];
}
[self.myTableView reloadData];
CGFloat newTableViewHeight = self.myTableView.contentSize.height;
self.myTableView.contentOffset = CGPointMake(0, self.myTableView.contentSize.height - oldTableViewHeight);
if i remove AutomaticDimension from my Delegate & .... it's work perfectly on static Height of Cell ,but i need AutomaticDimension to calculate height of my cell.