简体   繁体   English

在XCode中以编程方式执行segue后,空白ViewController

[英]Blank ViewController after programmatically performing segue in XCode

In my XCode project, which implements MultipeerConnectivity framework, I have a segue between two ViewControllers which is triggered programatically after MPCHandler successfully establishes connection with another peer. 在实现MultipeerConnectivity框架的XCode项目中,我在两个ViewController之间有一个顺序,该顺序是在MPCHandler成功与另一个对等方建立连接之后以编程方式触发的。 After segue is performed, the destination VC appears being completely blank (all white). 执行隔离之后,目标VC看起来完全空白(全白)。 However, if I try to access the destination VC with help of a button (with segue dragged directly from the button to the destination VC), it appears as it should. 但是,如果我尝试在按钮的帮助下访问目标VC(将segue直接从按钮拖到目标VC),它将按应有的方式显示。 Here is the line of code, which performs the segue: 这是执行segue的代码行:

    performSegueWithIdentifier("seg_wait", sender: self)

So, yeah, I know how to perform segues and, yes, I made sure identifier is unique and is the same as in storyboard. 所以,是的,我知道如何执行搜寻,是的,我确保标识符是唯一的,并且与情节提要中的标识符相同。 I had tons of segues in many of my projects, and that's the first time I've faced a problem like this. 在我的许多项目中,我都遇到了很多麻烦,这是我第一次遇到这样的问题。 Did anyone face a problem like this? 有人遇到过这样的问题吗? Any ideas on how to solve it? 关于如何解决的任何想法?

UI updates always have to be done on the main thread ("the law"). UI更新始终必须在主线程上完成(“法律”)。 So try to wrap the call: 因此,尝试包装该调用:

dispatch_async(dispatch_get_main_queue(), {
    performSegueWithIdentifier("seg_wait", sender: self)
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM