Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

Ionic 4: The “src” content of an “img” tag is not updating when I change it from the controller in IOS

$
0
0

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:

enter image description here

After:

enter image description here

But in IOS this isn’t working. The view is not updated at all

Before:

enter image description here

After:

enter image description here

Nothing appears, just a few letters. But the view doesn’t update in IOS.

What could it be?

My specifications:

enter image description here

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>