Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a custom UITableViewCell with objects in it (such as UILabel, UITextView, UITextField etc.). When a button gets selected, a cell gets added to the tableView.

When I run it on the simulator, and the cell gets added, the tableView jumps to the top for a second then scrolls to position.

Objective-C
...
[[self myTableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationTop];

[[self myTableView] scrollToRowAtIndexPath:indexPath 
                      atScrollPosition:UITableViewScrollPositionTop 
                              animated:YES
];


(I already tried myTableView begin/endUptades and it didn't help.)
Posted

1 solution

does the obvioius
Objective-C
self.tableView.scrollEnabled = NO;

not work?

You can also override the scroll handler
Objective-C
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
   [self.tableView setContentOffset:CGPointMake(0, contentOffset)];
}
 
Share this answer
 
Comments
Member 11360293 21-Mar-15 23:24pm    
That won't work, because the user will scroll at other times.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900