简体   繁体   中英

How to set force device orientation based on device type in React Native?

I've a React Native app, for some screens in that app, I need to set landscape view for tablet and for other portrait in mobile.

Although my question is same as below question, the only difference being mine is a React native, so I'll need solution for both Android and iOS

Android: How set force device orientation by device type (tablet, phone)?

From many answers of this question, what we get is that to identify whether the device is a tablet or a phone, you can use either this package's isTablet() or this package's isMobile and isTablet .

After identifying, next from the resource provided by this question's answer, you can lock or unlock the device's orientation.

The expo documentation link provided above as the resource will help you lock the orientation no matter what the platform or OS is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM