Creating a checkmark inside a Pickerview [duplicate]
I am developing an application where i want to create a checkmark on the selected row by the user.
For Ex.
In UITableView there is UITableViewCellAccessoryCheckmark;
But i am wondering is there something similar available for UIPickerView.
Any tutorial or pointer to get this behaviour?
I've made a UIPickerView subclass which can be used to implement this functionality. It forwards touch events to its superview and can therefore suppress the default behavior where entries are selected as they scroll past the middle.
The checkmark can be implemented by, as pertert writes, creating a custom UIView with an UIImageView and a UILabel for the pickerview's entries via the delegate method:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
You can find the project containing my subclass on Github.
精彩评论