gpt4 book ai didi

ios - 在应用程序启动时锁定到纵向从横向旋转到纵向(iOS)

转载 作者:行者123 更新时间:2023-11-29 11:31:19 42 4
gpt4 key购买 nike

我想将应用的首屏方向锁定为纵向。在某些屏幕上,我需要横向。我正在使用 react-native-orientation插入。但是当我启动该应用程序时,我会看到一段时间的横向,然后快速旋转到纵向。接下来的屏幕是好的。

这是我的代码:

componentDidMount() {
Orientation.lockToPortrait();
}

是否可以解决此性能问题?

最佳答案

在延迟方向锁定的页面中添加以下代码:

componentWillMount(){
Orientation.lockToPortrait();
Orientation.addOrientationListener(this._orientationDidChange);
}

_orientationDidChange(orientation) {
Orientation.lockToPortrait();
}

componentWillUnmount() {
// remove listener
Orientation.removeOrientationListener(this._orientationDidChange);
}

关于ios - 在应用程序启动时锁定到纵向从横向旋转到纵向(iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53222179/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com