Playing back table contents when using UIRefreshControl and configuring the contents of the INSET

So, I have a standard subclass of UITableViewController with a table view. Now I have set the content insert for

self.tableView.contentInset = UIEdgeInsetsMake(40, 0, 0, 0); 

I also use UIRefreshControl in a standard way.

 self.refreshControl = [[CTRefreshControl alloc] init]; [self.refreshControl addTarget:self action:@selector(loadData:) forControlEvents:UIControlEventValueChanged]; 

Everything works fine and smoothly if the table view contains enough data that it scrolls (so that the height of the content size is greater than the height of the table). When there is not enough data in the table (for example, only 2 rows), then when I start to go down, it goes smoothly, and then suddenly it jumps about 20 points down. The same thing happens when I scroll in a different direction. This does not happen when there is no update control or when I do not change the contentInset. Any ideas? All on iOS 6.

+7
ios uitableview ios6 uirefreshcontrol
source share
1 answer

You need to put a change to the contents of the Inset 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]; 

(printed from memory, so you may have to check for code completion).

This should solve your problem.

+1
source share

All Articles