2013-03-06 68 views
2

我有一个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]; 
       }); 
       }); 
       }]; 
} 
+0

做tableView reloadData的工作?如果没有,让它在主线程上运行 – mashdup 2013-03-06 17:03:34

+0

reloadData确实有效......如果我把这个方法放在其他任何地方,这些单元不会加载。 – Morkrom 2013-03-06 17:34:53

回答

3

可以尝试更改此行

[self.tableView addSubview:refreshControl]; 

[self setRefreshControl:refreshControl]; 
+0

很高兴我能帮忙:) – AC1 2013-03-06 23:21:56

相关问题