微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Avatar 在 ios 中不会改变,但在 android 中

如何解决Avatar 在 ios 中不会改变,但在 android 中

我有一个应用程序,在这个应用程序中我有用户系统,所以当我更改用户头像时,它在 web/android 平台中更改,但在 ios 平台中没有更改,我使用电容和cordova,所以请检查我的代码并帮助我解决我遇到的问题,以及我必须为 ios 平台放置哪些代码

这是问题所在的屏幕截图 enter image description here 这是一些代码。 这是我的 app.component.ts

     this.events.subscribe('avatar:change',(result) => {
        if (result == 'ok') {
            this.get('avatar').then(result => {
                this.avatar = result;
            });
        }
    });
}

这是change-avatar.html

<ion-content padding>
<input type="file" id="fileLoader" #fileLoader name="files" title="Load File" hidden />
<div class="modal">
    <ion-row no-padding>
        <ion-col size="8" offset="2">
        <!--<ion-item>-->
            <img id="checkinImage" [src]="uploadImage"/>
            <!--<ion-avatar *ngIf="isAvatar()">
                <img id="checkinImage" [src]="uploadImage"/>
            </ion-avatar>
            <ion-avatar *ngIf="isAvatarMiss()">
                <img id="checkinImage" src='./assets/img/avatar.png'/>
            </ion-avatar>
        </ion-item>-->
            <!--</span>-->
        </ion-col>
    </ion-row>
    <ion-row no-padding>
        <ion-col size="8" offset="2">
            <button ion-button full (click)="presentActionSheet(fileLoader)">Escollir nou avatar</button>
            <button margin-top ion-button full (click)="changeDone()">Aplicar</button>
            <button margin-top ion-button full (click)="openPrefsPage()">EL MEU PERFIL D'USUARI</button>
        </ion-col>
    </ion-row>
</div>

这里是change-avatar.ts

presentActionSheet(fileLoader) {
this.avatarMiss = false;
this.avatarLoaded = true;
fileLoader.click();
let that = this;
fileLoader.onchange = function () {

  let file = fileLoader.files[0];
  let reader = new FileReader();
  reader.onload = function(event) {
    that.uploadImage = reader.result as string;
    that.set('avatar',that.uploadImage);
    console.log('image',that.uploadImage);
  };

  /*
  reader.addEventListener(
    'load',function () {
      that.uploadImage = reader.result as string;
      that.set('avatar',that.uploadImage);
      // console.log(that.uploadImage);
    },false);
    */

  if (file) {
      reader.readAsDataURL(file);
  }
    // that.events.publish('avatar:change','ok');
  };
}



changeDone() {
this.events.publish('avatar:change','ok');
this.navCtrl.pop();

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。