[英]Can't push view controller in AppDelegate with TabBarController
[英]Can't push view controller while in its own function
我做了一個UIViewController,上面有一個Completion處理函數,因為它必須從數據庫中加載數據,那里的代碼是:
func S0000 () {
let V = self.storyboard!.instantiateViewControllerWithIdentifier("V0003") as! V0003
V.Cv { (Con) -> Void in
NSOperationQueue.mainQueue().addOperationWithBlock {
self.showViewController(V, sender: self)
}
}
}
這引發了錯誤:
fatal error: unexpectedly found nil while unwrapping an Optional value
我如何使它正常工作以及我在做什么錯。
僅作為參考,我發現以這種方式運行它可以正常工作,但是推入It時ofcours尚未完成加載,因為它在完成處理程序返回之前就進行了推入。
func S0000 () {
let V = self.storyboard!.instantiateViewControllerWithIdentifier("V0003") as! V0003
self.showViewController(V, sender: self)
V.Cv { (Con) -> Void in
NSOperationQueue.mainQueue().addOperationWithBlock {
}
}
}
嘗試這個
V.Cv { (Con) -> Void in
NSOperationQueue.mainQueue().addOperationWithBlock {
let V = self.storyboard!.instantiateViewControllerWithIdentifier("V0003") as! V0003
self.showViewController(V, sender: self)
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.