开发者

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 any开发者_StackOverflow中文版one point me to some code to do this? Thanks

How can I get a check mark beside UIPickerView labels?


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.


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:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜