鸿蒙开发中 SaveButton 按钮 保存按钮点击后权限授权失败。

原因分析 

查看官方文档的解释

在 控制台中 过滤这个字段

过滤关键字"SecurityComponentCheckFail"可以获取具体原因。

得到 产生的原因

是 因为层叠的原因     savebutton 组件必须的  在屏幕的最高层  不能有任何的覆盖和遮挡

通过这样书写就解决了

 // 下面是安全控件
        Column(){
          SaveButton(this.SaveButtonOptions)
            .backgroundColor('#FC3F41')
            .onClick(async (event:ClickEvent, result:SaveButtonOnClickResult) => {
              if (result == SaveButtonOnClickResult.SUCCESS) {
                componentSnapshot.get("水印照片", (error: Error, pixmap: image.PixelMap) => {
                  if (error) {
                    console.log("error: " + JSON.stringify(error))
                    return;
                  }
                  //将pixelMap打包为图片格式
                  const imagePackerApi = image.createImagePacker();
                  let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 };
                  // 将数据照片保存到相册中
                  saveToFile(pixmap,getContext(this))
                  imagePackerApi.packing(pixmap, packOpts).then( (data : ArrayBuffer) => {
                    // data 为打包获取到的文件流,写入文件保存即可得到一张图片
                    this.upload(data)
                  }).catch((error : BusinessError) => {
                    console.error('Failed to pack the image. And the error is: ' + error);
                  })
                })
              }
            })
        }
        .position({
          x:'68%',
          y:'77%'
        })
        .border({
          width:1,
          color:'#E60012'
        })
        .zIndex(3)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值