It seems I am not going to get this working. I need last page cells only for fraction of time and then I reset back to original tableview frame.
int rows = [tableview numberOfRowsInSection:0];
int numberofRowsInView = 17;
for (int i = 0; i < ceil((float)rows/numberofRowsInView); i++) {
NSUInteger remainingCells = rows - i*numberofRowsInView;
if(remainingCells < numberofRowsInView) {
CGRect frame = tableview.frame;
frame.size.height = remainingCells * tableview.rowHeight;
tableview.frame = frame;
}
[tableview scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:i * numberofRowsInView inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
......
}
Now it shows exactly remained cells on last page! I don't need to set contentSize anymore.