1

This is an iOS/Swift app. I use Fusuma, a camera library, for getting access to camera, taking photos and display them. Neat and easy.

Then I get to the part where I want to upload photos to server by POSTing their paths(in camera roll, I suppose).

So how do I do that? I did some search, seems like no clear answer in Swift.

Code like:

class ReceiptSaveViewController: UIViewController, FusumaDelegate {

...

@IBOutlet weak var photo1: UIImageView!
@IBOutlet weak var photo2: UIImageView!
@IBOutlet weak var photo3: UIImageView!
@IBOutlet weak var photo4: UIImageView!

...

@IBAction func takePhoto(sender: SwiftyButton) {
        // Show Fusuma
        let fusuma = FusumaViewController()

        // fusumaCropImage = false

        fusuma.delegate = self
        self.presentViewController(fusuma, animated: true, completion: nil)
    }

...

// MARK: FusumaDelegate Protocol
    func fusumaImageSelected(image: UIImage) {

        print("Image selected")
        let photos = [photo1, photo2, photo3, photo4]
        //let btns = [btn1,btn2,btn3,btn4]
        for photo in photos {
            if photo.image == nil {
                photo.image = image
                //btns[photo.tag - 1].alpha = 1
                return
            }
        }
    }
...
}
Fate Riddle
  • 364
  • 1
  • 3
  • 15

1 Answers1

0

I think you can see this link How can i get original nsdata of uiimage?. it use ALAssetsLibrary which has been replaced in swift ios 9 I think. see how to replace ALAssetsLibrary in ios 9 here How to use PHPhotoLibrary like ALAssetsLibrary ALAssets replaced by PHPhotoLibrary(Photo.framework) for ios 9.

or you can see the absolute URL of the image using this method Acquiring absolute image file path using iOS Swift use the image represented by FusumaImageSelected.

correct me if I'm wrong.

Community
  • 1
  • 1