I have a UITableView with around 50 entries. There is a edit/done button that toggles the edit mode. Now, whenever edit or done is pressed I would like to scroll the list to the top.
I tried several commands dirently in the setEditing method. This works for all entries except when the focued entries were the last 2-3 in the list. In this case, the list is scroll far to high (about 5 entries) so that blank space above the table view is in view.
Actually, I was using this to scroll
Code:
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
but I also tried this
Code:
[self.tableView scrollRectToVisible:CGRectMake(0.0, 0.0, 1.0, 1.0) animated:YES];
(same effect)
Also, I expermented with the content offset
Code:
[self.tableView setContentOffset:CGPointMake(0.0, 0.0) animated:YES];
Nothing seems to help. If the user toggles the edit mode while table view is all the way at the bottom, the view scrolls far too high.
Does anybody have an idea what the problem is?
Thanks