I have a Split View controller for iPad that should support both orientations (portrait and landscape).
The problem is that when I change the device's orientation the details view doesn't readjust to use the whole space and a grey square appears.
I don't think is a problem with the constraints because this only happens when I rotate:
- When I launch the app in portrait mode the layout loads good.
- When I launch the app in landscape mode the layout loads good.
In the SplitViewController (and also in the DetailsController) I tried this code:
In the viewDidLoad:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "rotated", name: UIDeviceOrientationDidChangeNotification, object: nil)
and then:
override func shouldAutorotate() -> Bool {
print("should rotate --> true")
return true
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
print("we support all orientations")
return UIInterfaceOrientationMask.All
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
print("preferred orientation for presentation is landscape")
return UIInterfaceOrientation.LandscapeLeft
}
func rotated(){
print("rotatiooooonn ------------")
refreshIpad()
detailSplitViewController.refreshUI()
}
func refreshIpad (){
dispatch_async(dispatch_get_main_queue(),{
self.view.setNeedsLayout()
})
}
In the logs I get this (so I can see whenever the change in orientation happens)
should rotate --> true
we support all orientations
rotatiooooonn ------------
Below is the info file:
EDIT
Constrains in Details View: