I am developing an app for Android and IOS.
I have a profile page where the user can change profile pictures. The photo appears in the view and is changed in real time.
My code is like this in the view:
<img alt="logo" style="width:15vh; height:15vh; border-radius: 50%;" src="{{pictureusuariomenu}}">
pictureusuariomenu is a variable found in the controller.
With that variable what I do is, it is the URL of the image that I upload, I update it there. here is the function:
updateStoredImages(name) {
this.storage.get(STORAGE_KEY).then(images => {
let arr = JSON.parse(images);
if (!arr) {
let newImages = [name];
this.storage.set(STORAGE_KEY, JSON.stringify(newImages));
} else {
arr.push(name);
this.storage.set(STORAGE_KEY, JSON.stringify(arr));
}
let filePath = this.file.dataDirectory + name;
let resPath = this.pathForImage(filePath);
// alert(resPath);
this.urlImage=resPath;
let newEntry = {
name: name,
path: resPath,
filePath: filePath
};
this.images=[]; //borrar las imagenes anteriores (no crear la lista de imagenes)
this.images = [newEntry, ...this.images];
this.urlImage = this.images[0].path;
this.colocarImagenEnProfile(this.urlImage);
this.ref.detectChanges(); // trigger change detection cycle
});
}
In this line:
this.colocarImagenEnProfile(this.urlImage);
What I do is:
colocarImagenEnProfile(newFileName){
this.pictureusuariomenu=newFileName;
}
Now in android is working fine this way of updating the profile image in view:
Before:
After:
But in IOS this isn’t working. The view is not updated at all
Before:
After:
Nothing appears, just a few letters. But the view doesn’t update in IOS.
What could it be?
My specifications:
1 post - 1 participant