Creating a checkmark inside a Pickerview [duplicate]

[亡魂溺海] 提交于 2019-12-12 20:20:31

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4690792/creating-a-checkmark-inside-a-pickerview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!