uni-app iOS 自定义基座 本地真机调试
uni-app iOS 自定义基座 本地真机调试
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Windows | Windows 11 | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Windows
HBuilderX类型:正式
HBuilderX版本号:4.45
手机系统:iOS
手机系统版本号:iOS 17
手机厂商:苹果
手机机型:iphone 12 16
页面类型:vue
vue版本:vue3
打包方式:云端
项目创建方式:HBuilderX
示例代码:
onLoad( () => {
// #ifdef APP-PLUS
setTimeout(() => {
plus.screen.unlockOrientation();
plus.screen.lockOrientation('landscape-primary');
}, 2200)
// #endif
});
mainifest.json
配置了
"ios": {
"UISupportedInterfaceOrientations": [
"UIInterfaceOrientationPortrait",
"UIInterfaceOrientationLandscapeLeft",
"UIInterfaceOrientationLandscapeRight"
],
},
"screenOrientation": [
"portrait-primary",
"landscape-primary",
"portrait-secondary",
"landscape-secondary"
],
"distribute": {
"ios": {
"dSYMs": false,
"screenOrientation": "landscape",
"orientation": "landscape"
},
}
操作步骤:
iOS A页面点击后跳转B页面横屏展示不全,Android没问题
预期结果:
A页面点击后跳转B页面横屏应该展示完全
实际结果:
A页面点击后跳转B页面横屏应该展示不完全
bug描述:
iOS A页面点击后跳转B页面横屏展示不全,Android没问题
更多关于uni-app iOS 自定义基座 本地真机调试的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
根据你描述的问题,iOS端横屏显示不全可能是由于以下原因导致的:
-
manifest.json配置问题: 你在manifest中同时配置了
screenOrientation
和distribute->ios->screenOrientation
,这可能导致冲突。建议统一使用screenOrientation
配置即可。 -
页面样式适配问题: iOS横屏时可能需要特殊处理页面布局,建议检查B页面的CSS样式是否适配横屏模式,特别是:
- 使用
vw/vh
单位替代固定像素 - 确保容器宽度为100%
- 检查是否有固定高度的元素
- 横屏切换时机问题: iOS对屏幕旋转的处理较严格,建议调整横屏切换代码:
onLoad(() => {
// #ifdef APP-PLUS
plus.screen.lockOrientation('landscape-primary');
// #endif
});