문제

I have implemented pull to refresh in a table view that is a subview to my main view like so:

UITableViewController *tableViewController = [[UITableViewController alloc] init];
tableViewController.tableView = self.tableView;
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
tableViewController.refreshControl = self.refreshControl;

This updates the table and everything fine, the problem I'm having is when I touch the table to drag the cells seem to randomly shift up above the screen. This happens when I touch and drag from the middle of the screen down, or if I pull before the the cells shift back to their normal position. Here are some screen shots to better paint a picture. Keep in mind that all of these are taken after I drag down, yet the cells shift upward.

Should look like:

enter image description here

actually looks like these after the cells jump:

enter image description here enter image description here

도움이 되었습니까?

해결책

For anyone that may be having this issue or an issue like this I found a way to get the scroll to refresh to work very smoothly and not cause the issues I was having. I'm using an actual UITableViewController now instead of an embedded UITableView which helped with some of the scroll issues, but I still had an issue where instead of animating the closing of the refresh icon (table sliding up to cover the spinning circle) it just shut instantly and seemed very jarring. I put my refresh logic in the background, let it finish and then finished refreshing. My code structure is as follows:

- (void)viewDidLoad {
    //set up refreshcontrol to call my refresh method
}

- (void)refresh {
    [self performSelectorInBackground:@selector(getUpdatedInfo) withObject:nil];
}

Updated info runs and my TableViewController is a delegate of my class that gets refreshed information. When all the information is received and the update is completed I call the delegate method in my refreshing TableViewController class that puts the received array into the table, updates the table, and ends refreshing.

- (void)didFinishingUpdatingWithArray:(NSArray *)array {
    //configure table sections
    //Save the data
    [self.tableview reloadData];
    [self.refreshControl endRefreshing];
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top