This video shows how to disable rotation in React Native iOS apps.
You may have noticed that by default React Native apps can be rotated. You can see this in the iOS simulator if you click command-left, or command-right to rotate the simulated device. There we go, rotating to the right. Now you can see that the orientation gives quite a different sort of layout that you have to deal with. This landscape orientation is really quite different from the portrait one.
When you’re developing your app, the best practice would be to develop in a way that it will look good in either orientation, but that can be difficult to do at time. If you want to just disable that rotation and make it so that the app can only be used in perhaps the portrait orientation, here’s how you can do that.
What you want to do is go to Xcode, open the project in Xcode. What you’re going to do is the same that you do with in fact any IOS app. This isn’t going to be something that’s specific to React Native. What you do is your open up the app here, project, and you want to make sure that you’ve got the general tab selected. Go down here and make sure you’ve got awesome projects as the target. You got a number of different device orientations here under the deployment info section – portrait, upside down, landscape left and landscape right. What you want to do is just to disable the two landscape modes. There we go. Rebuild your app.
When this starts up again, we will try again doing the rotation, so command-left and command-right arrow to rotate the simulated device. Here we go, so now we’ll rotate left, and you can see that the display stays in the same orientation. It doesn’t follow the physical rotation, the rotation of the device. We can rotate it to the right, and there we go. It’s the same that way as well.
So you can see, that keeps your life a lot simpler when you’re first developing an app. You don’t have to worry about two different orientations.