开发者

index for UIPickerView like UITableView?

Is it possible to have an index for a UIPickerView like one can have an index for a UITableView on the right hand side of the UITableView?

The reason I am asking is that if one has a large list of items in the UIPickerView, it can take quite a开发者_运维技巧 while to scroll to the end of the list.


You might want to consider using a UITableView, but that doesn't answer your original question. Anything is possible with a little imagination, and just because you can't do something effortlessly in Cocoa doesn't mean you shouldn't try at all!

I put together a small demo project that shows one way of doing it. Basically, it involves a UIView subclass that attaches itself to a UIPickerView. It allows you to associate index titles (NSStrings) with rows in the UIPickerView, and when you touch the titles, it scrolls to the appropriate row.

You could improve it by adding support for picker views with more than one component, improving the touch handling, adding custom label support, etc.


UIPickerViews are not designed to present a large list of items. Is there a reason why you can not just use a UITableView?


Maybe the only way to do so is customize a UITableView, let it looks like a UIPickerView.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜