Reputation: 5834
I saw many answers in SO which describes how can I scroll UITableView to the specific position.
I use setContentOffset
for scrolling to particular position.
I meet a weird issue. If my tableView
is half scrolled then setContentOffset
is working properly. But when I scroll to end of the tableView
and then use setContentOffset
, table view scrolls a little bit more.
My setContentOffset
value is CGPoint(0,199)
.
[self.tableView setContentOffset:CGPointMake(0,199) animated:NO];
After reaching a bottom I use setContentOffset
. Then I check the contentOffset
of UITableView
. and it is 169
.
I am not able to figure it out what exactly the issue is.
Edit::
I am using the following code. When a button in the last cell is pressed:
- (void)userPressedSubmitButtonOnLastCell
{
[self updateData];
[self.tableView reloadData];
[self performSelector:@selector(scrollTableView) withObject:nil afterDelay:0.5];
}
- (void)scrollTableView
{
[self.tableView setContentOffset:CGPointMake(0,199) animated:NO];
}
Upvotes: 1
Views: 1550
Reputation: 1598
Why don't you use tableView scrollToRowAtIndexPath:
or tableView scrollRectToVisible:(CGRect)
? This will allow you to scroll to either specific row or rectangle. ContentOffset
is more suitable for UIScrollView
.
Upvotes: 1