React Native iOS 标准和缩放显示

MD *_*hir 0 ios react-native

我在 RN iOS 应用程序中遇到问题。当显示为标准时,一切都很好,但是当缩放时,顶部栏完全混乱,用户无法单击顶部栏中的任何任何内容。尝试过SafeAreaView但没有帮助解决这个问题。

问题有什么方法可以查明显示是缩放还是标准?

MD *_*hir 9

这是查找显示是缩放还是标准的解决方案

import DeviceInfo from 'react-native-device-info'

const DEVICES = [
    'iPhone X',
    'iPhone XS',
    'iPhone XS Max',
    'iPhone XR'
]

const DEVICE_STANDARD_HEIGHTS = {
    "iPhone X": 812,
    "iPhone XS": 812,
    "iPhone XS Max": 896,
    "iPhone XR": 896,
}


const { height, width } = Dimensions.get("window");

const device_name = DeviceInfo.getModel();


let is_zoomed = false;

if (DEVICES.includes(device_name)) {
    if (DEVICE_STANDARD_HEIGHTS[device_name] > height) { // because when display is zoomed height is less than the standard display
        is_zoomed = true;
    }
}
Run Code Online (Sandbox Code Playgroud)

根据您的要求修改它:)