Duncan Tilka
Duncan Tilka

Reputation: 79

How do i select multiple (2-5) images for an Image picker then return as image view?

Hey so I'm trying to have a button that when pressed allows the user to choose 2-5 pictures from their photo library then have whatever photo chosen be set onto a uiimageview? I was looking online and couldn't find anything related to how to do it in swift? Thanks

Upvotes: 5

Views: 2951

Answers (2)

Alvin George
Alvin George

Reputation: 14294

I worked out using this : https://github.com/zhangao0086/DKImagePickerController .

Getting selected image's thumbnail images:

let pickerController = DKImagePickerController()
pickerController.sourceType = .Photo
pickerController.didCancelled = { () in
    println("didCancelled")
}

pickerController.didSelectedAssets = { [unowned self] (assets: [DKAsset]) in
    println("didSelectedAssets")
    println(assets)

    for(var i = 0; i<(assets.count); i++){
        print(assets[i].url)

        self.PickedArray .addObject(assets[i].thumbnailImage!)
}

self.performSegueWithIdentifier("SegueToPhotoLibraryView", sender: self)

Getting selected image's urls :

assets[i].url instead of assets[i].thumbnailImage

Hope it helps!

Upvotes: 1

The Lone Coder
The Lone Coder

Reputation: 3104

Currently iOS does not provide an image picker out of the box that lets you pick multiple images from the photo library. UIImagePickerController only lets you select one image.

But there are several image picker implementations available that let you pick multiple images. You can find a whole bunch at cocoacontrols.com as @ytbryan already mentioned.

I am currently not aware of any multiple image picker implemented in Swift. If someone finds one, please edit and post the link.

Upvotes: 0

Related Questions