UIView rotation doesn't work properly in Swift

649 views Asked by At

My UIViewshould always be in fullscreen but that doesn't really work sometimes. Every time the user rotates the device, the method viewWillLayoutSubviews gets called.
Here I print the height and width of the UIView.
The height and width of the UIView are right (1024 width,768 height in landscape mode).
Anyway, on the iPad the View hasn't this size altough I write it to the Console.
In portrait mode everything works, but in landscape not so what could be the problem? If the iPad is in landscape mode and I start the app it works but if I rotate it (then it's portrait) and rotate it back to landscape, the view isn't in fullscreen anymore.

1

There are 1 answers

2
matt On

Simply pin the edges of your UIView to the edges of the view controller's main view with constant of 0, once when you add the UIView to the interface, and all will be well thereafter.