iphone - How to apply an user interface orientation to an iOS storyboard scene -


i developing ios application allows play 1 of 2 different games.

both games played in set of rounds. when player finishes round application transitions new scene displays results , either transitions round scene or end game scene.

because of transient nature of scenes in application, makes little sense persist scenes done in more traditional applications, can return previous scene.

to end, scene navigation accomplished using uinavigationviewcontroller , calling setviewcontrollers(animated:) supplying array contains uiviewcontroller next scene, , works quite well.

i mentioned application allow play 1 of 2 games. turns out that, on iphone, 1 game best played in portrait mode, , other game works best played in landscape mode. want able control user interface orientation used particular uiviewcontroller when becomes active.

i have experimented using supportedinterfaceorientations property of uinavigationcontroller , application(_ application: supportedinterfaceorientationsfor window:) uiapplicationdelegate, , have been able things work standard application. however, when try apply things way game application works using setviewcontrollers(animated:), no methods pertain applying desired user interface orientation seem called, , scenes appear @ same orientation.

what suggestions people have how scene in application appear particular user interface orientation?

try making presented view controller call following method on it's view appear, or view did appear:

class func attemptrotationtodeviceorientation() 

some view controllers may want use app-specific conditions determine interface orientations supported. if view controller this, when conditions change, app should call class method. system attempts rotate new orientation.

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621400-attemptrotationtodeviceorientati


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -