[英]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.