Search code examples
iphoneiosasynchronousuirefreshcontrol

UIRefreshControl hangs indefinitely


I have a UIRefreshControl, and it works fine when you use it, but it hangs, it never goes away. I've tried

[self.refreshControl endRefreshing];

This solution was from a similar question, but it has not addressed mine.

Even with this, the refreshControl continues spinning, not dismissing. Why is this?

In my viewDidLoad:

[NSThread detachNewThreadSelector:@selector(refreshFeed) toTarget:self withObject:nil];

refreshControl = [[UIRefreshControl alloc] init];

[refreshControl addTarget:self
                   action:@selector(refreshFeed)
         forControlEvents:UIControlEventValueChanged];

[self.tableView addSubview:refreshControl];

refreshFeed method...

-(void)refreshFeed
//load those feeds
{
RSSLoader* rss = [[RSSLoader alloc] init];    
[rss fetchRssWithURL:feedURL
            complete:^(NSString *title, NSArray *results) {
                dispatch_queue_t downloadQueue = dispatch_queue_create("downloader",NULL);
                dispatch_async(downloadQueue, ^{

                _objects = results;

                //completed fetching the RSS
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self.refreshControl endRefreshing];
                    [self.tableView reloadData];
                });
                });
                }];
}

Solution

  • Can you try changing this line

    [self.tableView addSubview:refreshControl];
    

    with

    [self setRefreshControl:refreshControl];