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
- view controller - landscape
- vc - portrait
- vc- portrait
- vc -landscape
- 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