旋转到横向离子4 IOS时为半白屏

问题描述 投票:0回答:1

我正在以人像模式构建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中,如下图所示,屏幕的一半被白色覆盖。

enter image description here

[请帮助我解决此问题

ionic-framework ionic4 screen-orientation
1个回答
0
投票

通过将摄像机预览的大小修改为]解决了该问题>

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)
      });
  }
© www.soinside.com 2019 - 2024. All rights reserved.