Get last image from Photos.app?

后端 未结 13 2063
萌比男神i
萌比男神i 2020-11-27 09:50

I have seen other apps do it where you can import the last photo from the Photos app for quick use but as far as I know, I only know how to get A image and not the last (mos

13条回答
  •  眼角桃花
    2020-11-27 10:25

    Refer to answer by Liam. fullScreenImage will return a scaled image fitting your device's screen size. For getting the actual image size:

      ALAssetRepresentation *representation = [alAsset defaultRepresentation];
      ALAssetOrientation orientation = [representation orientation];
      UIImage *latestPhoto = [UIImage imageWithCGImage:[representation fullResolutionImage] scale:[representation scale] orientation:(UIImageOrientation)orientation];                    
    

    Quoting Apple's ALAssetRepresentation Class Reference on fullResolutionImage:

    To create a correctly-rotated UIImage object from the CGImage, you use imageWithCGImage:scale:orientation: or initWithCGImage:scale:orientation:, passing the values of orientation and scale.

提交回复
热议问题