iOS手机上的锁定筛选方向
我正在使用React-Navigation(Expo + Vscode + Windows)从一个屏幕导航到另一个屏幕,我必须将屏幕方向从肖像变为景观和环境。
仅通过使用选项(请参见下文),它在Android上完美工作,
<Stack.Screen
name={MainFlowKeys.Home}
component={Home}
options={{ orientation: "portrait_up" }}
/>
但这对iOS不起作用。我使用物理设备对其进行测试(iPhone SE)。
因此,我尝试使用Expo模块(屏幕定位),但它是故障的(加载时屏幕旋转,但然后用户可以将其重新旋转,但未锁定)。
我正在使用此功能:
export const forceLandscape = async () => {
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT);
};
它在每个页面中都触发了:
useEffect(() => {
if (Platform.OS === "ios") forcePortrait();
}, []);
但是它也不起作用(我的意思是屏幕旋转,但用户可以后来旋转它,但不会锁定)
如何解决此问题?我缺少什么?
I'm using react-navigation (expo + VScode + Windows) to navigate from one screen to another, and I have to change the screen orientation from portrait to landscape and the reverse way around.
It works perfectly on android, just by using the options (see below)
<Stack.Screen
name={MainFlowKeys.Home}
component={Home}
options={{ orientation: "portrait_up" }}
/>
but this DOESN'T work on IOS. I use a physical device for testing it (iphone SE).
So I've tried to use an expo module (screen-orientation), but it's buggy (the screen is rotated when loaded but then the user can rotate it back afterward, it's not LOCKED).
I'm using this function:
export const forceLandscape = async () => {
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT);
};
It's trigerred in each page with:
useEffect(() => {
if (Platform.OS === "ios") forcePortrait();
}, []);
but it doesn't work as well (I mean the screen rotates but the user can rotates it back afterward, it's NOT locked)
How to solve this? What is it I am missing ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论