Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How does the uiviewcontroller react to orientation changes?


Asked by Adele Stout on Dec 13, 2021 React



This is poorly designed because a UIView should not react directly to orientation changes. This is the job of the UIViewController. Moving on, the UIDeviceOrientation is the current orientation of the device itself, not of the user interface currently displayed within the device.
Furthermore,
A UIViewController has 3 major responsibilities: Layout out its component UIView s. This includes sizing, responding to orientation changes, etc. iOS provides a number of standard view controllers such as UINavigationController, UITabBarController, and UIPageViewController.
In respect to this, The intersection of the app's orientation mask and the view controller's orientation mask is used to determine which orientations a view controller can be rotated into. You can override the preferredInterfaceOrientationForPresentation for a view controller that is intended to be presented full screen in a specific orientation.
Keeping this in consideration,
The UIViewController class defines the shared behavior that is common to all view controllers. You rarely create instances of the UIViewController class directly. Instead, you subclass UIViewController and add the methods and properties needed to manage the view controller's view hierarchy.
Indeed,
If you want to use UIDeviceOrientation to rotate some of your views, then you need to ignore some of the UIDeviceOrientation values. Specifically, you need to ignore the Unknown, FaceUp, and FaceDown values.