'How to scroll to the top of a table view in iOS 15
How do you scroll to the very top of a table view in iOS 15?
These ways don't seem to work.
[self.tableView setContentOffset:CGPointZero animated:YES];
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
This way worked great in prior versions, but iOS 15 puts new padding above each table header section, and this no longer scrolls to the exact top in iOS 15.
It scrolls to the first table header section, but below it's padding, so about 20 pixels off from the very top.
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
