iosuitableviewscreen-orientationuiinterfaceorientationdevice-orientation

iOS part of viewcontroller goes black when orientation changes


When I change viewcontroller orientation while it's loading on particular orientation, part of the screen goes blank at the bottom.

Steps to reproduce:

  1. Have tableview(Not necessary I think. could be any view) in a view controller
  2. Push a new viewcontroller which also has a tableview(Not necessary I think. could be any view) during an action
  3. Rotate the screen from one orientation to Another(Portrait to landscape or landscape to portrait).now you will be able to see the dark part.
  4. Press back button to pop the current viewcontroller
  5. Now rotate from one orientation to Another(Portrait to landscape or landscape to portrait).now you will be able to see the dark part here as well.

The bottom part of viewcontroller goes black.

I am able to reproduce 7 out of 10 times.

FYI:

My Viewcontroller has only tableview that's all and all cells has autolayout constraints. Trying to understand why it happened and I would like to fix it.

More details on reproducing the issue:

Basically you can reproduce this issue only if you hold your device in slanting position and either push or pop a view controller and while the page is trying to load , you have to change the orientation then the issue happens.

(Pun intended.... lol ) In other words ,you have to tilt you device as if you are steering the wheel :).

This issue can only happen if you use your device like a steering wheel :)


Solution

  • In one view controller(Parent the one that pushes new view controller) setting the frame at viewDidLayoutSubviews solves the issue in another view controller(The child view controller , one that's getting pushed) setting the frame at viewWillTransition fixes the problem :) But still I don't know why there's no universal solution to this problem.