我在 RN iOS 应用程序中遇到问题。当显示为标准时,一切都很好,但是当缩放时,顶部栏完全混乱,用户无法单击顶部栏中的任何任何内容。尝试过SafeAreaView但没有帮助解决这个问题。
问题有什么方法可以查明显示是缩放还是标准?
这是查找显示是缩放还是标准的解决方案
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)
根据您的要求修改它:)
| 归档时间: |
|
| 查看次数: |
3301 次 |
| 最近记录: |