简体   繁体   中英

NavigationController in swift leads to a black screen

I'm trying to use a navigation controller for an identification process in my swift code but each time I click on a button that leads to it, it shows the following black screen:

IOS模拟器上的黑屏

Here is my storyboard if this can helps, there is no warning and no error in the code (using a drag and drop segue or a programmatically one leads to the same black screen)

我的故事板与segues

Probably the segue you picked: mode & transition.

Are you certain you only have a single segue ? It is possible to have overlapping segues, which do not show up clearly in Interface Builder.

Edit

Is there a way we can see all our segues?

  1. Open the Storyboard in its new window
  2. Show Document Outline (leftmost pane)
  3. Show Attribute Inspector (rightmost pane)
  4. Select each View Controller Scene in the Document Outline. The Segues are listed at the bottom. You can inspect Identifier and Segue in the Attribute Inspector.

在此处输入图片说明

Sounds, I was doing the wrong way (drag a nav controller, delete the table view, add a new View controller and make the segue), but now if I create a view, and then I embed it in a navigation controller it sounds it works ! Anyway, thanks a lot for your help, this definitely helps me !

I got this when I assigned a custom view to self.view in viewDidLoad: .

self.view = self.mapView

Adding mapView as a subview of self.view solved this.

[I see you've created a custom ViewController, are you sure it's a subclass of ViewController?

You can see which subclass is it off after the ":" in the class declaration! 图片

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