代码之家  ›  专栏  ›  技术社区  ›  SmoggeR_js

如何在iOS React原生应用程序中将方向锁定为纵向?

  •  0
  • SmoggeR_js  · 技术社区  · 7 年前

    我试图取消勾选“设备方向设置”,让“单独肖像”选项处于勾选状态,但它不起作用。在Android系统中,它不旋转,但在iOS系统中是这样的,我不知道为什么。它在我的整个应用程序中旋转,不管我是哪个窗口。 你知道另一种锁定方向引起的旋转的方法吗?

    这是我的信息。列表:

    <?xml version=“1.0”encoding=“utf-8”?gt;
    &!doctype plist public”-//apple//dtd plist 1.0//en“”http://www.apple.com/dtds/propertylist-1.0.dtd“>
    <plist version=“1.0”>
    DICT & GT;
    <key>cfbundledevelopmentRegion</key>
    <string>en</string>
    <key>cfbundledisplayname</key>
    <string>下一个门户</string>
    <key>cfbundleExecutable</key>
    <string>$(可执行文件名)</string>
    <key>cfbundleIdentifier</key>
    <string>$(产品捆绑标识)</string>
    <key>cfbundleInformationDictionaryVersion</key>
    <string>6.0</string>
    <key>cfbundlepackagetype</key>
    <string>应用</string>
    <key>cfbundleshortversionstring</key>
    <string>7.7</string>
    <key>cfbundlesignature</key>
    字符串?????</string>
    <key>cfbundleversion</key>
    <string>12</string>
    <key>lsrequiresiphoneos</key>
    和/和;
    <key>nsAppTransportSafety</key>
    DICT & GT;
    <key>不允许使用位图加载</key>
    和/和;
    &;
    <key>nscamerausagedescription</key>
    <string>$(product_name)necesita acceser a su c_mara para poder escanear el c_3 digo qr.</string>
    <key>不使用时的位置说明</key>
    <string></string>
    <key>nsmainnibfile</key>
    <string>启动屏幕</string>
    <key>nsmainnibfile~ipad</key>
    <string>启动屏幕</string>
    <key>nsmicrophoneusaged说明</key>
    <string>$(product_name)想要您的麦克风(用于视频)</string>
    <key>nsphotoolibraryaddusagedescription</key>
    <string>$(product_name)necesita acceser a la galer_–a para adjuntar fotos.</string>
    <key>nsphotoolibraryusagedescription</key>
    <string>$(product_name)necesita acceser a la galer_–a para adjuntar fotos.</string>
    <key>uiappfonts</key>
    数组& gt;
    <string>entypo.ttf</string>
    <string>evilicons.ttf</string>
    <string>羽毛.ttf</string>
    <string>fontawome.ttf</string>
    基金会。TTF & lt;/String & Gt;
    <string>离子图标.ttf</string>
    <string>材料通信图标.ttf</string>
    <string>唯物主义.ttf</string>
    <string>八进制图标.ttf</string>
    <string>simplelineicons.ttf</string>
    <string>zocial.ttf</string>
    &Lt/数组& gt;
    <key>ui启动存储板名称</key>
    <string>启动屏幕</string>
    <key>uiRequiredDeviceCapabilities</key>
    数组& gt;
    <string>ARMV7</string>
    &Lt/数组& gt;
    <key>ui要求全屏显示</key>
    和/和;
    <key>ui支持界面方向</key>
    数组& gt;
    <string>ui界面方向纵向</string>
    &Lt/数组& gt;
    <key>uiviewcontrollerbasedstatusbarappearance</key>
    和/假;
    &;
    <PLIST & GT;
    < /代码> <我不知道为什么。它在我的整个应用程序中旋转,不管我是哪个窗口。
    你知道另一种锁定方向引起的旋转的方法吗?

    enter image description here

    这是我的信息列表:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleDisplayName</key>
        <string>NEXT PORTAL</string>
        <key>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
        <key>CFBundleIdentifier</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>7.7</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>12</string>
        <key>LSRequiresIPhoneOS</key>
        <true/>
        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
        <key>NSCameraUsageDescription</key>
        <string>$(PRODUCT_NAME) necesita acceder a su cámara para poder escanear el código QR.</string>
        <key>NSLocationWhenInUseUsageDescription</key>
        <string></string>
        <key>NSMainNibFile</key>
        <string>LaunchScreen</string>
        <key>NSMainNibFile~ipad</key>
        <string>LaunchScreen</string>
        <key>NSMicrophoneUsageDescription</key>
        <string>$(PRODUCT_NAME) would like to your microphone (for videos)</string>
        <key>NSPhotoLibraryAddUsageDescription</key>
        <string>$(PRODUCT_NAME) necesita acceder a la galería para adjuntar fotos.</string>
        <key>NSPhotoLibraryUsageDescription</key>
        <string>$(PRODUCT_NAME) necesita acceder a la galería para adjuntar fotos.</string>
        <key>UIAppFonts</key>
        <array>
            <string>Entypo.ttf</string>
            <string>EvilIcons.ttf</string>
            <string>Feather.ttf</string>
            <string>FontAwesome.ttf</string>
            <string>Foundation.ttf</string>
            <string>Ionicons.ttf</string>
            <string>MaterialCommunityIcons.ttf</string>
            <string>MaterialIcons.ttf</string>
            <string>Octicons.ttf</string>
            <string>SimpleLineIcons.ttf</string>
            <string>Zocial.ttf</string>
        </array>
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIRequiredDeviceCapabilities</key>
        <array>
            <string>armv7</string>
        </array>
        <key>UIRequiresFullScreen</key>
        <true/>
        <key>UISupportedInterfaceOrientations</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
        </array>
        <key>UIViewControllerBasedStatusBarAppearance</key>
        <false/>
    </dict>
    </plist>
    
    3 回复  |  直到 7 年前
        1
  •  0
  •   Sandy.....    7 年前

    请执行以下步骤,将React Native iOS应用程序中的方向锁定为纵向:

    1] Open Your_React_Native_Project -> go to ios -> project_name.xcodeproj file in X-Code.
    2] After opening the project in Xcode, select your project name.
    3] Now Goto -> General -> Deployment Info and select device orientation as portrait.
    4] Execute the "react-native run-ios" command and compile the entire project. Now you can see the effect.
    

    另外,据观察,如果“设备”设置为“通用”,方向锁在iPad上似乎不起作用。如果换成了iPad,它就可以正常工作了。

        2
  •  0
  •   SmoggeR_js    7 年前

    最后,我找到了答案。不是我期望的解决方案,因为我认为锁定就足够了 XCode 正如我之前在问答中提到的,但至少它起作用了。

    我安装 react-native-orientation 我应用了 Orientation.lockToPortrait() 函数的构造函数 App.js 文件和它锁定应用到肖像。

    希望有帮助!

        3
  •  -1
  •   Helmer Barcos    7 年前

    尝试清理项目,重新构建应用程序,也许它会有所帮助。一旦我无法锁定设备方向,唯一的方法就是勾选肖像选项。

    推荐文章