admin管理员组

文章数量:1128493

I tried locking a single screen using useEffect and lockAsync with unlockAsync in the cleanup.

import {lockAsync, OrientationLock, unlockAsync} from 'expo-screen-orientation';
useEffect(() => {
    const lockOrientation = async () => {
      await lockAsync(OrientationLock.PORTRAIT);
    };

    lockOrientation();

    return () => {
      const unlockOrientation = async () => {
        await unlockAsync();
      };

      unlockOrientation();
    };
  }, [])

The cleanup function is not working - when I change screen I cannot change orientation any longer. If I add unlockAsync in the other screens then the orientation can change again.

Is there another way to lock the orientation of a single screen?

本文标签: react nativelock orientation of single screen with exposcreenorientationStack Overflow