1and2papa / CTAssetsPickerController

iOS control that allows picking multiple photos and videos from user's photo library.
MIT License
2.15k stars 550 forks source link

Want to Limit the Photo selection #132

Closed hassan31 closed 9 years ago

hassan31 commented 9 years ago

Hello everyone, Is there any way to limit the selection of Photos in this pickerviewcontroller? Like I want to select 3 photos only from this pickerViewController.

Thanks Hassan

1and2papa commented 9 years ago

@hassan31 Check the demo app. There is an example showing what you are exactly looking for.

hassan31 commented 9 years ago

Yes, I've already checked, but there is no option to limit the selection in the code.. As I can select as many as we can.

1and2papa commented 9 years ago

Have you checked the example "Maximum selection"? You have to implement the shouldSelectAsset delegate.

hassan31 commented 9 years ago

No, I didn't. Thanks I'll check it now. One thing more, when I select the images from AssetPicker, and go back or press done button on navigation bar, then I've the main Album View Controller which have also done and cancel buttons on navigation bar. when I press both of them, id does not dismiss the the ViewController instead teh app hangs.

Any idea?

nileshpol18 commented 8 years ago
func assetsPickerController(picker: CTAssetsPickerController!, shouldSelectAsset asset: PHAsset!) -> Bool {

    return picker.selectedAssets.count < 5 ? true : false
}