Limit the number of selectable images
Closed this issue · 2 comments
Is there a way to limit the number of total selectable images?
For example, in my case, I need to limit the selection to five images. Is it achievable in some way?
Late to the party, but GMImagePickerController
has an event named ShouldSelectAsset
, the event uses the Cancellable EventArgs strategy which means if you wish to cancel the selection you should set the it to cancelled in the arguments with args.Cancel = true;
and the cell should then not be selected.
If you combine that with the property GMImagePickerController.SelectedAssets.Count
then you should achieve the desired scenario.
var controller = new GMImagePickerController();
controller.ShouldSelectAsset += (sender, args) => args.Cancel = controller.SelectedAssets.Count > 5;
Yes, this is indeed the intended way of limiting image selection. This is very similar to how many API's in iOS work. Thanks @Duranom for chipping in.