如何通过单击在 ionic2 中打开的相机上的后退按钮导航到页面

how to navigate to a page by clicking back button on camera open in ionic2

我有一个主页,我在 ionViewWillEnter() 中添加了相机代码。这样当 HomePage 获得触发时,它会首先打开相机

我想自定义后退按钮的行为,当我按下后退按钮时,打开相机后它应该导航到第二页,默认情况下它导航到主页。

ionViewWillEnter() {
   this.captureVideo();
 }


 captureVideo() {
    platform.registerBackButtonAction(() => {
      this.navCtrl.push(SecondPage)
       });
    let options: CaptureVideoOptions = { limit: 1 };
    this.mediaCapture.captureVideo(options)
     .then((videodata: MediaFile[]) => {
      var i, path, len;
     for (i = 0, len = videodata.length; i < len; i += 1) {
      path = videodata[i].fullPath;

      }

      this.flag_play = false;
      this.flag_upload = false;


     this.file.resolveLocalFilesystemUrl(path).then((newUrl) => {
     alert(JSON.stringify(newUrl))
     let dirPath = newUrl.nativeURL;
     let dirPathSegments = dirPath.split('/')
     dirPathSegments.pop()
     dirPath = dirPathSegments.join('/')
     this.file.readAsArrayBuffer(dirPath, newUrl.name).then(async (buffer) 
        => {
        await this.upload(buffer, newUrl.name);

          })

        })
        })
     .then(() => {


       var videoFileName = 'video-name-here'; 

       this.videoEditor.createThumbnail(

        {
         fileUri:'abc',// this.videoId,
         outputFileName: videoFileName,
         atTime: 2,
         width: 320,
         height: 480,
         quality: 100
        }
       ).then(result => {



     this.result = result;
     this.base64.encodeFile(result).then((base64File) => {
      this.base64Thumbnail = base64File.replace("*;charset=utf-8", "jpg")

       }, err => {

       alert("Unable to create thumbnail")
      })

       })
       })

       }

硬件后退按钮用作取消的默认行为...因此要对其进行自定义,请将您的特定代码放入错误中...

  takePicture(){
    this.camera.getPicture({
       destinationType: this.camera.DestinationType.DATA_URL,
      targetWidth: 1000,
      targetHeight: 1000
     }).then((imageData) => {
  // imageData is a base64 encoded string
       this.base64Image = "data:image/jpeg;base64," + imageData;
    }, (err) => {
   this.navCtrl.pop();

   });
  }
  }