开发者

IS there a UITableView with alphabetic or numeric index in the view?

Is there a specific UITableView set of methods that will generate a UItableView with an alphabetic or numeric index along the side similar to what appears when you bring up the AddressBook?

I want to provide a large amount of data from a datasource in a table listing format with an accessible index on the display similar to AddressBook. The AddressBook has the alphabet displayed on the right, which the user can tap to be taken down to that level of detail. I need to do something similar.

I want to use a numeric index. It would be "nice to have" either an alphabetical or numeric accessible indexed UITableView.

I did search Apple's documentation as w开发者_运维知识库ell as StackOverFlow, didn't find anything, but who knows, I may be blind and not even know it. :)

Do I have to subclass UITableView? Or is there freeware framework available somewhere?


this is asked and answered a few times, basically it behavior that is built in, you will need to support more delegate/datasource methods.

the main method is – sectionIndexTitlesForTableView: and tableView:sectionForSectionIndexTitle:atIndex: keep in mind that this only works in plain style tableViews.


UITableViewDataSource method

sectionIndexTitlesForTableView:

Asks the data source to return the titles for the sections for a table view.

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

Parameters

tableView - The table-view object requesting this information.

Return Value

An array of strings that serve as the title of sections in the table view and appear in the index list on the right side of the table view. The table view must be in the plain style (UITableViewStylePlain). For example, for an alphabetized list, you could return an array containing strings “A” through “Z”.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜