I want to use a tableview as a picker. For example, when selecting a ringtone for a contact a tableview of ring tones appears.
What is the i开发者_如何学运维deal way to accomplish this? It seems like this would be very common.
Thanks for your time.
Make your table view delegate implement - (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath
and you can tell which row was selected. http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBIQFjAA&url=http%3A%2F%2Fdeveloper.apple.com%2Fiphone%2Flibrary%2Fdocumentation%2Fuikit%2Freference%2FUITableViewDelegate_Protocol%2FReference%2FReference.html&ei=VotlTKCfMsP98AaczJT6Bw&usg=AFQjCNFjM7H_oPMFgqw3oadcBDsd9st0_g&sig2=NypngpJbn1_7CRDXwIuyfw
If you want it scrolling infinitely, you might find this component useful: http://dev.doukasd.com/2011/04/infinite-scrolling-dial-control-for-ios/
UITableView
and UIPicker
are two different things, so be careful using the word "picker" in this content.
You're basically asking "how do I present and control a table view?". You're right, it is a very common theme in iPhone development, which is why Apple has a handy programming guide for doing just that, which links to several different sample code projects (I count 10 on their site under User Experience / Tables).
精彩评论