iSaBo
iSaBo

Reputation: 187

React-Native - iOS - disable manuel screen rotation

i use the React-Native "react-native-orientation" - Library.

Is it possible, to disable Screenrotation by the User? My App is the most time in Portrait mode. Some Views have a Landscape Orientation. Id like to disable the manuell rotation on Views with Portraitmode. I dont found a working way yet. Is it possible? If yes, how?

In xCode, i selected the Portrait, Landscape Left and Landscape Right-Mode. If i only check "Portrait", than the Views with Landscape do not work. So i checked all. But id like to disable manuell rotation by User.

Thanks for helping me

Upvotes: 0

Views: 541

Answers (1)

NiFi
NiFi

Reputation: 2458

As you stated, enabling all required rotation modes in the native configuration is necessary for the app to support rotating at all.

Custom rotation logic bound to a certain view is possible to add by using Orientation.lockToPortrait() and Orientation.unlockAllOrientations(). You probably want to bind these function calls to navigation actions or componentWillUnmount and similar component lifecycle events. API documentation: https://github.com/yamill/react-native-orientation#api.

Upvotes: 1

Related Questions