简体   繁体   English

如何在没有 xcode 的情况下禁用 react-native ios 中的应用轮换?

[英]How to disable app rotation in react-native ios without xcode?

I know that is possible to disable the rotation using XCode, but I do not have access to some Mac in the moment, then I wonder if there is a way to do that using VSCode, and not XCode.我知道可以使用 XCode 禁用旋转,但我目前无法访问某些 Mac,然后我想知道是否有办法使用 VSCode 而不是 XCode 来做到这一点。

You can easily achieve this without xcode, you just have to update the key UISupportedInterfaceOrientations in your projects Info.plist file.您可以在没有 xcode 的情况下轻松实现这一点,您只需更新项目Info.plist文件中的关键UISupportedInterfaceOrientations Although you won't be able to test it without xcode.尽管没有 xcode,您将无法对其进行测试。

You can search for the key UISupportedInterfaceOrientations in your projects Info.plist file and update the values as below.您可以在项目Info.plist文件中搜索关键UISupportedInterfaceOrientations并更新如下值。 If you don't see any such key then simply create a new key and values as below:-如果您没有看到任何此类键,则只需创建一个新键和值,如下所示:-

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

This would set the orientation on ios enabled as Portrait, Landscape Right and Landscape Left.这会将 ios 上的方向设置为纵向、横向右侧和横向左侧。 If you only want it to Portrait just paste the code below:-如果您只想将其显示为肖像,只需粘贴以下代码:-

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>

You can simply change the orientation property in your App.json您可以简单地更改App.json中的方向属性

"orientation": "portrait" or "orientation": "portrait"
"orientation": "landscape"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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