简体   繁体   中英

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. After segue is performed, the destination VC appears being completely blank (all white). 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. Here is the line of code, which performs the 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"). So try to wrap the call:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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