개발일지_2023.04.17(월) - React Native 가로모드 or 세로모드 고정하기

guddls ju·2023년 4월 20일
1

개발일지

목록 보기
2/3

React Native 앱 실행시 가로, 세로를 고정하는 방법에 대해서

1. AOS (android)

앱 설정파일 AndroidManifest을 변경해주면 된다.

android/app/src/main/AndroidManifest.xml
위 경로로 들어가서 코드를 한줄 추가해줍니다. (예시는 세로모드 고정)

  • 가로모드 : landscape
  • 세로모드 : portrait
<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


2. IOS (iphone)

ios/projectname/Info.plist
에서 남기고 싶은 모드만 남기면 됩니다

<key>UISupportedInterfaceOrientations</key>
<array>
	<!-- <string>UIInterfaceOrientationPortrait</string>
	<string>UIInterfaceOrientationLandscapeLeft</string> -->
	<string>UIInterfaceOrientationLandscapeRight</string>
</array>

그리고 pod install 해주기~

profile
효율에 미친자

0개의 댓글