reactjs - react-native-orientation 库中的 lockToPortrait() 函数出错
问题描述
我正在使用react-native-orientation库使我的应用程序仅以纵向模式打开。这是我的代码:
import React, {Component} from 'react';
import {
View,
Text,
} from 'react-native';
import AppContainer from './src/screens/Navigation';
import Orientation from 'react-native-orientation';
const App: () => React$Node = () => {
useEffect(() => {
Orientation.lockToPortrait();
})
return (
<AppContainer />
);
};
export default App;
我在运行此代码时遇到错误。
解决方案
对于 android,您只需将此行添加到 MainActivity 标记中的 AndroidManifest.xml 即可设置方向 android
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" //add this line for portrait lock
android:windowSoftInputMode="adjustPan">
在 ios 打开 xcode 文件后执行此操作
推荐阅读
- reactjs - 有没有办法让组件中的样式标签具有非常低的优先级?
- android - WebView 无法在 GoogleDrive 中播放视频
- sql - 如何在sql server中划分每个员工为一个服务用户提供的小时数
- javascript - 使用 Chart.js 更改度量单位的颜色
- prolog - 为什么我的序言谓词在得到第一个答案时停止?
- hook - 想要从 helm 安装中排除 kubectl 作业
- javascript - 鼠标打开/鼠标关闭(悬停)问题
- java - JAVA-单元测试用例
- java - Java:按下 html 按钮在两个 Http Servlet 之间发送数据
- crystal-lang - Crystal 不为联合做自动推断类型?