HarmonyOS PhotoViewPicker设置isEditSupported后点击编辑,未得到想要的结果。

const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
      photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
      photoSelectOptions.maxSelectNumber =  9;
      photoSelectOptions.isEditSupported = true;
      let uris: Array<string> = [];
      const photoViewPicker = new photoAccessHelper.PhotoViewPicker();
      photoViewPicker.select(photoSelectOptions).then((photoSelectResult: photoAccessHelper.PhotoSelectResult) => {
        uris = photoSelectResult.photoUris;
        resolve({
          code: 0,
          uris: uris
        })
      }).catch((err: BusinessError) => {
        reject({
          code: err.code,
          uris:[]
        })
      })

调用系统级,图片选择器设置允许编辑,但点击编辑按钮后,未能到编辑页面。

HarmonyOS
1天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
put_get

使用到picker编辑图片能力时,建议使用new picker.PhotoViewPicker();来生成 photoPicker 对象,示例demo:

import { photoAccessHelper } from '@kit.MediaLibraryKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import picker from '@ohos.file.picker';
@Entry
@Component
struct PhotoPickerPage2 {
  @State img: string = ''
  aboutToDisappear() {
  }
  build() {
    Column() {
      Button("Button")
        .onClick(() => {
          let photoPicker = new picker.PhotoViewPicker();
          photoPicker.select(
            {MIMEType: 'image/*', maxSelectNumber: 1, isPhotoTakingSupported: true, isEditSupported: true, isSearchSupported: false} as photoAccessHelper.PhotoSelectOptions
          ).then((res) => {
            if (res.photoUris.length > 0) {
              this.img = res.photoUris[0]
            }
          }).catch((err: BusinessError) => {
            hilog.info(1, "hilog",'select error: ' + err.code + ' ' + err.message)
          })
        })
      Image(this.img)
    }.width('100%').margin({ top: 5 })
  }
}
分享
微博
QQ
微信
回复
1天前
相关问题
TextInput 怎么设置不可编辑
2313浏览 • 1回复 待解决
HarmonyOS photoViewPicker智能推荐不生效
349浏览 • 1回复 待解决
后点击展开文本
253浏览 • 0回复 待解决
HarmonyOS PhotoViewPicker 保存到图库
696浏览 • 1回复 待解决
想要Harmonyos实战
9627浏览 • 3回复 待解决