我在桌面上使用UIRefreshControl
來更新項目。最後,我展示了一個UIAlertController
來通知用戶更新已完成,並更新了多少項。非常簡單,一件事情可以正常工作。如果我連續刷新幾次,有時甚至在關閉警報後刷新控制也不會被解除。我需要向上滑動桌子才能消失。UIAlertController有時會阻止UIRefreshControl隱藏
這是我使用的代碼,所有UI的東西是很好做在主線程:
if(refreshControl.refreshing) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self refreshItems];
dispatch_async(dispatch_get_main_queue(), ^{
[refreshControl endRefreshing];
[self.tableView reload];
[self showUpdateInfo];
});
});
}
任何想法可能是什麼原因?
編輯:這是我在代碼中創建刷新控制(在viewDidLoad
):
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString: @"Checking for updates…"];
[refreshControl addTarget: self
action: @selector(refreshOutdatedItems)
forControlEvents: UIControlEventValueChanged];
self.refreshControl = refreshControl;
你在代碼中創建的UIRefreshControl或使用TableViewController財產? – Yan
請參閱我的問題中的編輯。 – Koen
我試圖重現該問題。您的代碼似乎按預期工作。順便說一句,你有dispach_sync,實際上墜毀在我身上。這是故意的還是應該是dispatch_async? – Yan