Search code examples
iosswiftuiviewcontrolleruiinterfaceorientation

UIViewController blank in portrait mode, but subviews are visible in landscape mode?


A very strange thing happened. I created a UIViewController in IB and used

detailController = self.storyboard?.instantiateViewControllerWithIdentifier("detailView")
self.navigationController?.pushViewController(detailController!, animated: true)

to reveal the view. But the strange thing is that it presented a blank screen in portrait mode, and a correct view in landscape mode, as the screenshots shows

I tried

self.presentViewController(traceInfoController!, animated: true, completion: nil)

and it didn't help either.

My codebase is relatively large and I have already commented out all the codes for orientation adapting.

Any ideas how such thing happens and how to correct it?

enter image description here

enter image description here


Solution

  • Thanks everyone! I just figured it out!

    I didn't remember when I changed the layout mode to (wAny hCompact) in IB!

    enter image description here

    Look at the small text in the last line, saying iPhone in landscape! So this is the way to design different layouts for different screen sizes!

    To solve the problem, just change to (wAny hAny) then edit.