1
votes

My first view controller is in landscape. When a button is pressed the second vc need to be displayed in portrait mode. I programmatically create the button depending on frame width. But the portrait vc gives the Width

(self.view.frame.width) = 1024 instead of 798.

That creates problems to hide my buttons and some interface issue.

The interface codes:

override func shouldAutorotate() -> Bool {

return true
}

override func supportedInterfaceOrientations() -> Int {

return Int(UIInterfaceOrientationMask.PortraitUpsideDown.rawValue)

}

And in info.plist, and project settings orientation.All the orientations is checked

My view controller hierarchy

  1. view controller - landscape
  2. vc - portrait
  3. vc- portrait
  4. vc -landscape
  5. vc - portrait

So I am not able to change one orientation in info.plist

Updated:

When i change in info.plist supported orientations all to portrait.And remove the above code means there is no problem.

But the issue is when use

      override func supportedInterfaceOrientations() -> Int {

return Int(UIInterfaceOrientationMask.PortraitUpsideDown.rawValue)

}

It display the view in portrait mode but give the width and height same as landscape mode.

But when changes all in info.plist it gives correct portrait height and width.

How can solve it.

Thanks

1

1 Answers

0
votes

I just create a custom view , if i need portrait means width 768 and height 1024, in viewDidload that solves my problem