MBProgressHUD不能立即顯示問題

今天使用HUD在tableview的代理方法didSelectRowAtIndexPath中使用HUD不能立即顯示

這裏寫圖片描述

問題原因

UIKit 不能在當前run loop結束前重畫,即需要在下一個run loop 週期才能重畫,更新UI。

解決方案

手動運行NSRunLoop
即:

// Setup and show HUD here

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantPast]];

// Insert your code here
// Hide the shown HUD here
發佈了46 篇原創文章 · 獲贊 37 · 訪問量 13萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章