There is a tableview. It is necessary during the approximation of a cell from the top (let indexPath.row = 1) run a query to add data to the table. Accordingly, the user must stay where he was and flipped through the table. This happens, for example, in the VK application, while viewing a dialogue. You scroll through and see how the slider itself goes down below.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if ((indexPath.section == 0) && (indexPath.row == 1)) { [self loadMore]; } } This is where I launch the update method. Next, it starts the call to the server. By answering which I do the following:
CGFloat initialOffset = self.tableView.contentOffset.y; [self.tableView reloadData]; [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:items.count inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; CGPoint afterContentOffset = self.tableView.contentOffset; CGPoint newContentOffset = CGPointMake(afterContentOffset.x, afterContentOffset.y + initialOffset); self.tableView.contentOffset = newContentOffset; Where items is the new items that came to be displayed in the table.
And it works almost as it should, but loading stops the user. This does not happen smoothly.
Does someone know how to do the same as dialogs in VC work?
Those. Need precisely smoothness work.