UIRefreshControl: UITableView 'stuck' while refreshing

前端 未结 1 1128
野的像风
野的像风 2021-02-10 09:33

I\'m having a problem implementing UIRefreshControl - in that when you pull down, the \'blob\' works perfectly fine and the refresh spinner works fine, but the tableView doesn\'

相关标签:
1条回答
  • 2021-02-10 10:27

    You can change to following

    - (void)refreshView:(UIRefreshControl *)refresh  {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            // (...code to get new data here...)
            dispatch_async(dispatch_get_main_queue(), ^{
                //any UI refresh
                [self.refreshControl endRefreshing];
            });
        });
    }
    

    -refreshView: will get called on the main thread, and all UI updates are using the main thread. So if you use the main thread for "code to get new data" it will "stuck"

    0 讨论(0)
提交回复
热议问题