React Native 앱 실행시 가로, 세로를 고정하는 방법에 대해서
앱 설정파일 AndroidManifest을 변경해주면 된다.
android/app/src/main/AndroidManifest.xml
위 경로로 들어가서 코드를 한줄 추가해줍니다. (예시는 세로모드 고정)
<activity
android:name=".MainActivity"
android:label="@string/app_name"
// 여기에 코드를 추가합니다.
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
그리고 터미널에서 안드로이드 폴더에 들어가서 그레들 클린해주면 적용됩니다.
명령어)
cd android
./gradleW clean
ios/projectname/Info.plist
에서 남기고 싶은 모드만 남기면 됩니다
<key>UISupportedInterfaceOrientations</key>
<array>
<!-- <string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string> -->
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
그리고 pod install 해주기~