UIRefreshControl无限期挂起

时间:2013-03-06 15:27:26

标签: iphone ios asynchronous uirefreshcontrol

我有一个UIRefreshControl,当你使用它时它工作正常,但它挂起,它永远不会消失。我试过了

[self.refreshControl endRefreshing];

此解决方案来自类似的question,但它没有解决我的问题。

即使这样,refreshControl仍继续旋转,而不是解散。为什么是这样?

在我的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方法......

-(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];
                });
                });
                }];
}

1 个答案:

答案 0 :(得分:3)

您可以尝试更改此行吗

[self.tableView addSubview:refreshControl];

[self setRefreshControl:refreshControl];