我正在以人像模式构建IONIC 4应用。我已迫使该应用在config.ts文件中保持纵向模式,并且在android和iOS中都可以正常工作
在某些页面上,我正在使用相机预览插件自定义相机屏幕。它需要处于横向模式,因此请使用“屏幕方向”插件将其强制在该页面上横向放置并启动相机。
ngOnInit() {
this.platform.ready().then(()=>{
if(this.platform.is('cordova')){
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
this.cameraPreview.onBackButton().then(()=>{
console.log('Back button pushed');
this.close();
})
// this.presentAlertConfirm()
//make short delay of 500ms to start the camera preview
setTimeout(()=>{
this.initCameraPreview()
},500)
}
})
}
在android中工作正常。
但是在IOS中,如下图所示,屏幕的一半被白色覆盖。
[请帮助我解决此问题
通过将摄像机预览的大小修改为]解决了该问题>
async initCameraPreview(){
await this.cameraPreview.startCamera(
{
x: 0,
y: 0,
width: this.isIOS ? window.screen.height : window.screen.width,
height: this.isIOS ? window.screen.width : window.screen.height,
toBack: true,
previewDrag: false,
tapPhoto: false,
camera: "back"
}
).then(
(res) => {
console.log(res)
},
(err) => {
console.log(err)
});
}