IOS UITableView

来源:互联网 发布:广告公司用到的软件 编辑:程序博客网 时间:2024/05/20 01:44

我只能说,UITableView真是强大,原来通讯录右边的索引,tableView以后自带。

通过设置来个dataSource方法

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{    return [[UILocalizedIndexedCollation currentCollation] sectionIndexTitles];}
- (NSString *)tableView:(UITableView *)tableViewtitleForHeaderInSection:(NSInteger)section{    return [[[UILocalizedIndexedCollation currentCollation] sectionTitles] objectAtIndex:section];}

- (NSInteger)tableView:(UITableView *)tableViewsectionForSectionIndexTitle:(NSString *)title               atIndex:(NSInteger)index{    return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index];}


<pre code_snippet_id="473716" snippet_file_name="blog_20140923_1_384235" name="code" class="objc" style="color: rgb(51, 51, 51); font-size: 20px; line-height: 30px;">[[UILocalizedIndexedCollation currentCollation] sectionIndexTitles]对应不同语言的结果

http://code4app.com/ios/Contacts-Multi-Picker/5052a2396803fa8c31000000


Locale Section Index Titles
en_US A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, #
ja_JP A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, あ, か, さ, た, な, は, ま, や, ら, わ, #
sv_SE A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Å, Ä, Ö, #
ko_KO A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, ㄱ, ㄴ, ㄷ, ㄹ, ㅁ, ㅂ, ㅅ, ㅇ, ㅈ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ, #
AR_sa A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, آ, ب, ت, ث, ج, ح, خ, د, ذ, ر, ز, س, ش, ص, ض, ط, ظ, ع, غ, ف, ق, ك, ل, م, ن, ه, و, ي, #


UITableViewIndexSearch(可以用title == UITableViewIndexSearch 来判断,是一个NSString)
If the data source includes this constant string in the array of strings it returns in sectionIndexTitlesForTableView:, the section index displays a magnifying glass icon at the corresponding index location. This location should generally be the first title in the index.

这个就是一个放大镜图标,显示在通讯录右边缩影的第一个,也只能放在第一个才行,也只能在sectionIndexTitlesForTableView:中返回的数组中的第一个。作用是什么?只是显示?可以自己设置作用,比如点击后,出现搜索界面框。

0 0