akkyie/AKPickerView

Enhancement: Allow picker view to contain NSString or UIImage items similar to UISegmentControl

Closed this issue · 4 comments

One useful addition might be for enabling support of items that are NSStrings or UIImages similar to what is allowed with UISegmentControl. UISegmentControl supports setting an image or a title (not both) for each segment using the following interface:

- (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment;
- (void)setImage:(UIImage *)image forSegmentAtIndex:(NSUInteger)segment;

I haven't given much thought on how to implement this yet other than possibly adding a new AKPickerViewDelegate method:

- (UIImage *)pickerView:(AKPickerView *)pickerView imageForItem:(NSInteger)item;

And adding an image property to AKCollectionViewCell:

@property (nonatomic, strong) UILabel *image;

And a mode flag (specified at creation?) indicating which delegate method should be called and which collection view cell property will be populated.

I'm not crazy about the idea of a mode flag so maybe this isn't the best approach to adding this functionality.

An alternative idea would be to allow for optional setting both a title and image depending on if either or both delegate methods are implemented. In this way, the mode flag would not be necessary and the cell could do something like place the label above the image. This approach is probably a better solution.

OK now I am working on this. Stay tuned.

Hi Akkyie, are there any updates availailbe? I would like to use your PickerView with images. Thanks a lot for providing it :)

I am very sorry for my slow updating.
I had considered some points such as which should I do implementing delegate methods with texts and images only or rather making delegate methods view-based, and it has been unintentionally suspended by my private tasks eventually.
But I'd like to update it with image (or view) support in some days, and of course pull requests are still welcomed.
Thanks a lot for your support,

Thank you for waiting, now you can use AKPickerView with images (e279a0a.)
I think there still may be bugs or anything needs improvements. Please let me know if you find!