0

I have a problem in react-native, I'm creating a component in swift in order to do image processing. In my code, a picker selects the image from the gallery and returns the link of the image to me and then opens this image in my native code. My code works on two iPhones ( iPhone 6S on 12.3.1 and iPhone 7 on 12.3.1) but the link, once inserted in the UIImage object, returns me nil on iPhone 7 on 10.3.2 .

      let result = val!["filename"] == nil ? "" : val!["filename"]
      print(result)
      self.bg = UIImage(named: result as! String )
      if(bg == nil){
        print("ERROR : Nil image")
      }

So I do have the following messages that appears

/var/mobile/Media/DCIM/100APPLE/IMG_0628.JPG
ERROR : Nil image

Normally, there should be the image that generates well, but not in this version of iOS, is there something I missed? Another way to open the image in previous versions ?

SNW
  • 1
  • 1

1 Answers1

0

You are using the wrong method to get image. Actually method that you have used is consider when image need to get from Bundle or Assets.

You need to use following method to fix your issue.

self.bg = UIImage(contentsOfFile: result as! String)
Sagar Chauhan
  • 5,715
  • 2
  • 22
  • 56