【问题标题】:UIRefreshControl hangs indefinitelyUIRefreshControl 无限期挂起
【发布时间】:2013-03-06 15:27:26
【问题描述】:

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

[self.refreshControl endRefreshing];

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

即使这样,refreshControl 也会继续旋转,而不是关闭。为什么是这样?

在我看来DidLoad:

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

【问题讨论】:

  • tableView reloadData 工作吗?如果没有,让它在主线程上运行
  • reloadData 确实有效...如果我将该方法放在其他任何地方,则单元格不会加载。

标签: iphone ios asynchronous uirefreshcontrol


【解决方案1】:

你能不能换行试试

[self.tableView addSubview:refreshControl];

[self setRefreshControl:refreshControl];

【讨论】:

    猜你喜欢
    • 2017-06-29
    • 2011-05-07
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 2019-04-29
    • 2019-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多