Wrong image after navcontroller.setRoot


#1

Hello everyone. This is my first entry here.
Currently I am trying to solve some bugs of an app on iPhone X.
A very weird bug is that I have a page, let’s call it somePage, that has two different images. From another page, I do Navcontroller.setRoot(somePage) and window.localStorage.clear(), the two images look the same, are the same pic, on iPhone X.

Can someone help me a little?


#2

Can you share some code re this?


#3

This is the function that is called to the page I’m talking about:

logout(){
     this.events.publish('user:loggedOut', this.myStorage.getItem('name'));
     this.myStorage.clear();
     this.navCtrl.setRoot('MyPage');
   }

This is the images in question, on MyPage’s template:

         <ion-col col-6 text-center>
            <img tappable (click)="doSomething()" src="someurl" width="100%">
          </ion-col>
          
          <ion-col col-6 text-center>
            <img tappable (click)="doSomethingToo()" src="someurltoo" width="100%">
          </ion-col>

#4

What is the connection between anything that happens in logout() and anything that is supposed to be happening with these images? The only thing affecting whether the images would look the same given what you have posted is whether someurl and someurltoo are either identical or pointing to the same image, and logout() seems completely unrelated to that.


#5

logout() is suppose to only clear localstorage and setroot to MyPage. But on iOS, not on Android, the images are wrong after the setRoot.


#6

Given what you have posted, that is completely impossible, because someurl and someurltoo are string constants.

Therefore, you have elided away the actual cause of the problem between the code you are really running and what you have posted.


#7

Well that’s the reason I’m looking for help here. Maybe is something about cache? I tried everything: using constants, setting the URLs of the images in ionViewDidEnter(), etc.


#8

You’re not listening to what I’m saying, so somebody else is going to have to take over. Good luck.


#9

I did listen to you. I know they are constants. I am using constants right now, but on iPhone X there is this mysterious bug :frowning:. Maybe you would prefer this other version:

          <ion-col col-6 text-center>
            <img tappable (click)="doSomething()" [src]="someimg" width="100%">
          </ion-col>
          
          <ion-col col-6 text-center>
            <img tappable (click)="doSomethingToo()" [src]="someimgtoo" width="100%">
          </ion-col>

where someimg and someimgtoo are variables declared on constructor of MyPage and are never use on another place different from the template.