sarriaroman / photoviewer

PhotoViewer Cordova Plugin
MIT License
157 stars 213 forks source link

iOS: Previewing a photo just shows a black screen #146

Closed Alessandro100 closed 5 years ago

Alessandro100 commented 6 years ago

ionic-angular: ^3.9.2 @ionic-native/photo-viewer: ^4.7.0 com-sarriaroman-photoviewer: ^1.1.18 ios platform: 4.5.4 Tested on an iPhone running iOS 11.4.1

When viewing an image on android, it works perfectly but on iOS, viewing the same image just shows a black screen (does not crash the app). The way Im using it:

viewImage(image){ let options = { share: false, // default is false closeButton: true, // default is true copyToReference: true // default is false } this.photoViewer.show(image, this.request.title, options); }

When I tried putting share = true, then it would crash the app on iOS

jcuervo commented 5 years ago

@Alessandro100 pls try what I did on #128

LeoLR commented 5 years ago

If you try to show a local image in from assets, try this:

presentImage() {
        let options = {
            share: true, // default is false
            closeButton: true, // iOS only: default is true
            copyToReference: true // iOS only: default is false
        };
        this.photo.show(decodeURI(this.file.applicationDirectory + "www/assets/images/your-png.png"), "", options);
    }
Alessandro100 commented 5 years ago

@jcuervo Your solution works, decodeURIComponent was the answer

var options = {
      share: true, // default is false
      closeButton: true, // iOS only: default is true
      copyToReference: true // iOS only: default is false
 };
 if(platform.is('ios'){
     imgSrc = decodeURIComponent(imgSrc);
 }
this.photoViewer.show(imgSrc, title, options);

The image shows on iOS