今天逛devdiv发现这个了这个东西然后自己就写了个demo看看
以前看iphone app经常在table右边有一个列表。可以用于快速选择。
这个就是sectionIndexTitle了
设置sectionIndex
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;
此时是默认对应 顺序对应 sectionIndex根据顺序对应 到section
修改sectionIndex对应
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
通过传入的传入每个sectionIndex的title,index 来设置这个sectionIndex 对应的section。
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
//用于设置sectionIndexTitle
//返回要为一个内容为NSString 的NSArray 里面存放section title;
//默认情况下 section Title根据顺序对应 section 【如果不写tableView: sectionForSectionIndexTitle: atIndex:的话】
NSMutableArray* a=[NSMutableArray array];
for(CountryVO *c in self.countryDy){
[a addObject: [c.countryName substringToIndex:1]];
}
// return b=@[@"1",@"2"];
return a;
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
//传入 section title 和index 返回其应该对应的session序号。
//一般不需要写 默认section index 顺序与section对应。除非 你的section index数量或者序列与section不同才用修改
return index;
}
分享到:
相关推荐
ios中tableview下拉出发tableview更新的效果实现。 iPhone5.1 测试成功
IOS开发 tableview中cell的用法 值得拥有
tableView的多项选择删除
tableVIew点击展开
悬停+ tableviewheader
论坛有朋友因为嵌套tableview,没办法保存按钮的点击状态困惑了好多天,因此写了这个demo,想来会有人需要这样的代码,所以发布上来,大家互帮互助,不过本人代码风格不是很好,大家可以凑合参考一下思路,注释写的...
继承了刷新、空白页、数据请求 小小的封装不喜勿喷!github:https://github.com/MuYanQin/QQtableView.git
让Tableview 每个Section拥有圆角加阴影
ios开发 3d tableview效果不错哦
iOS tableview 展开与收回
IOS 折叠TableView 类似QQ好友列表的实现
demo中有详细解释
tableview编辑删除
空页面,tableview
在tableview的cell中显示一个倒计时demo给大家参考下暂时没实现获取毫秒的方法,如果大家有方法欢迎提出修改。。。感激不尽。
tableview 动态添加
很方便的实现自定义的tableview
TableView的Cell上播放视频
swift ,使用autolayout + storyboard 最外层tableview列表,cell里面嵌套了tableview,自适应内容,cell里的tableview不可滑动,内容全部显示,且文字分行显示,不用设置cell的高度直接可以自适应内容
在下边的小例子中,我们将先实现显示一列数据,然后在每行添加图像,之后再看看UITableViewCell的四种分别是什么样的。最后再进行其他操作,比如设置缩进、修改字体大小和行高等。