當我寫這樣的,它按預期工作:MBProgressHUD不顯示
然而,當我把它放在DispatchQueue.main塊,平視顯示器不顯示:
override func viewDidLoad() {
super.viewDidLoad()
DispatchQueue.main.async {
MBProgressHUD.showAdded(to: self.navigationController!.view, animated: true)
}
}
我調試視圖層次,並且有一個佈局問題:
「位置和大小曖昧MBProgressHUD」
navigationController是fatherViewController的childViewController,而容器視圖是在fatherViewController的視圖中通過自動佈局設置的。
這是否導致問題?
你可以寫'self.view',而不是'self.navigationController!.view' 或 你有你'UINavigationCotroller'在故事板添加如果你有比讓它作爲initialViewController連接爲RootViewControlller比高於嘗試添加' self.navigationController!.view' – Dhiru