我在RN iOS应用中遇到问题。当显示为标准时,一切都很好,但是当其为“缩放”时,顶部栏完全混乱,用户无法单击顶部栏中的任何内容。尝试了 SafeAreaView
,但没有找到原因。
有什么方法可以确定显示是缩放还是标准显示?
答案 0 :(得分:2)
这是查找显示是缩放还是标准的解决方案
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;
}
}
根据您的要求进行修改:)