So I have standard subclass of UITableViewController with table view. Now I have set content inset to
self.tableView.contentInset = UIEdgeInsetsMake(40, 0, 0, 0);
I'm also using UIRefreshControl in standard way.
self.refreshControl = [[CTRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(loadData:) forControlEvents:UIControlEventValueChanged];
All works fine and smoothly if table view contains enough data that it scrolls(so content size height is more than table view's height). When there is not enough data in table (e.g. only 2 rows) then when I start to pull down it goes smoothly and then suddenly it jumps by about 20 points down. Same thing happens when I scroll other direction. It doesn't happen when there's no refresh control or when I don't change contentInset. Any ideas? All on iOS 6.
You need to put the change of contentInset in an animation block like this...
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.tableView.contentInset = UIEdgeInsetsMake(40, 0, 0, 0);
}
completion:nil];
(Typed from memory so you may have to check code completion).
This should fix your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With