Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a check mark beside UIPickerView labels?

The UIPickerView that appears in Safari has a check mark beside the current choice. Is there a built-in way to get this, or do I have to program it up myself? If I do have to create it, can anyone point me to some code to do this? Thankscheck mark or tick

like image 312
nevan king Avatar asked Dec 15 '10 09:12

nevan king


2 Answers

Here is some official sample code for customizing UIPicker view: http://developer.apple.com/library/ios/#samplecode/UICatalog/Introduction/Intro.html

In particular, refer to classes PickerViewController.{h, m} , CustomPickerDataSource.{h, m} and CustomView.{h, m} in the example. You can create a similar custom UIPickerView with a tick image which gets displayed only to the left for the selected item and change the text color of selected item. Also, remember to set myPickerView.showsSelectionIndicator = NO; to remove the semi-transparent bar above the selected item.

like image 193
NP Compete Avatar answered Oct 20 '22 08:10

NP Compete


You need to implement -pickerView:viewForRow:forComponent:reusingView: from the UIPickerViewDelegate.

You have to create a view, that contains a UIButton with the checkmark image, and return it from -pickerView:viewForRow:forComponent:reusingView:

like image 28
vikingosegundo Avatar answered Oct 20 '22 07:10

vikingosegundo