`
119568242
  • 浏览: 430858 次
  • 性别: Icon_minigender_1
  • 来自: 深圳/湛江
社区版块
存档分类
最新评论

[ios]tableView section index

 
阅读更多

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

    //用于设置sectionIndexTitle

    //返回要为一个内容为NSString NSArray 里面存放section title;

    //默认情况下 section Title根据顺序对应 section 【如果不写tableView: sectionForSectionIndexTitle: atIndex:的话】

    NSMutableArray* a=[NSMutableArrayarray];

    int i=0;

    for(PersonnelInfoVO *p inpersonnelInfomArray){

        [a addObject: [NSStringstringWithFormat:@"%d",i]];

        i++;

    }

    

    

    //    self.tableView.sec

    //    self.tableView.sectionIndexTrackingBackgroundColor=[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];

    

    //    return b=@[@"1",@"2"];

    return a;

}

 

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{

 

    [tableView scrollToRowAtIndexPath:[NSIndexPathindexPathForRow:index inSection:0atScrollPosition:UITableViewScrollPositionNoneanimated:NO];

    //传入 section title index 返回其应该对应的session序号。

    //一般不需要写 默认section index 顺序与section对应。除非 你的section index数量或者序列与section不同才用修改

    return index;

 

}

分享到:
评论

相关推荐

    ios-tableView的多项选择删除.zip

    总的来说,"ios-tableView的多项选择删除.zip"项目涵盖了在iOS应用中实现tableView多选删除的核心步骤,包括开启多选模式、处理用户选择、展示选中状态以及实现删除功能。开发者可以根据自己的需求进行相应的扩展和...

    iOS tableview 索引

    侧边索引,也称为section index或快速索引,通常显示在tableView的右侧,以字母顺序排列,让用户能够迅速定位到以某个字母开头的条目。例如,在联系人应用中,你可以快速跳转到以"A"、"B"、"C"等开头的名字。 实现...

    ios-tableview 动态添加.zip

    "ios-tableview 动态添加.zip"这个压缩包很可能包含了一个示例项目,演示如何在运行时动态地向UITableView添加数据。在这里,我们将深入探讨在iOS应用中动态加载UITableView的相关知识点。 首先,UITableView的动态...

    ios-常用的taBleView样式.zip

    实现这个功能通常需要监听UITableView的代理方法,比如`tableView:sectionForSectionIndexTitle:atIndex:`来确定用户点击的是哪个索引,并用`scrollToRowAtIndexPath:atScrollPosition:animated:`方法来滚动到相应的...

    iOS tableView上拉刷新显示下载进度的问题及解决办法

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0]; [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; } ``` 这里,我们使用了...

    ios-tableviewcell的移动、删除、添加.zip

    - 更新UITableView:`tableView.moveRow(at: IndexPath(row: fromIndex, section: 0), to: IndexPath(row: toIndex, section: 0))` 4. **实现编辑模式**: 为了启用用户可以直观地拖动Cell进行移动或滑动出现删除...

    ios-SearchBar和tableView快速索引.zip

    在iOS开发中,`SearchBar`和`TableView`的结合使用是常见的用户界面设计,用于实现高效的搜索功能和快速索引。本项目“ios-SearchBar和tableView快速索引.zip”提供了一个`SearchBarDemo`示例,展示了如何将这两个...

    IOS UITableView及索引条源码

    同时,还需要实现`tableView:sectionForSectionIndexTitle:atIndex:`方法,将用户的触摸事件转换为实际的section。 6. 响应滚动:UITableView的滚动事件可以通过实现`scrollViewDidScroll:` delegate方法来监听,这...

    tableView右侧索引

    3. 添加右侧索引:通过实现`tableView:sectionForSectionIndexTitle:atIndex:`方法,告诉系统当用户点击索引栏中的哪个条目时,应该滚动到哪个section。同时,需要实现`sectionIndexTitlesForTableView:`方法来提供...

    ios 版实现汉字按字母排序(带索引的tableview)

    同时,`tableView:sectionForSectionIndexTitle:atIndex:`用来处理用户点击索引栏时的跳转逻辑,它根据点击的索引位置找到对应的首字母,然后计算出对应的Section,最后调用`scrollToRowAtIndexPath:...

    ios-Move-Delete-Insert-TableView.zip

    比如,`tableView.moveRow(at: IndexPath(row: oldIndex, section: 0), to: IndexPath(row: newIndex, section: 0))`将旧索引的行移动到新索引。 这些操作都需要确保数据源和表格视图保持同步,以避免出现视觉上的...

    Xamarin.iOS-UITableView详细使用说明

    如果需要,可以通过` tableView(_:titleForHeaderInSection:)`和` tableView(_:titleForFooterInSection:)`返回section的标题。 9. 自定义分割线: 可以通过设置`SeparatorStyle`和`SeparatorInset`属性调整表格...

    tableView之索引栏demo

    3. **实现索引回调**: 实现`tableView:sectionForSectionIndexTitle:atIndex:`代理方法,根据用户点击的索引调整显示的section。 4. **处理点击事件**: 同时,你需要在`tableView:didSelectRowAtIndexPath:`中更新...

    iOS 列表的单选

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return options.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> ...

    ios中右侧索引定位中文联系人

    在UITableView中,section index通常显示在右侧,用户可以通过点击字母来快速跳转到对应首字母的联系人列表。对于中文联系人,我们需要处理汉字的排序和索引生成。 1. **汉字排序**:在iOS中,我们可以使用`...

    IOS界面九宫格效果

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dataSource.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> ...

    获取汉字汉语拼音首字母,UITableView中文也可以加index了功能ios源码.zip

    - 实现`tableView:sectionForSectionIndexTitle:atIndex:`代理方法,根据用户点击的索引标题,定位到相应的section。 4. UI设计与交互: - 索引栏通常显示在右侧,可以自定义其颜色、字体等视觉样式。 - 考虑到...

    ios通讯录列表按字母筛选

    为了实现字母筛选,我们需要在界面上添加一个可滚动的字母索引栏(通常称为“section index”),让用户可以快速跳转到以特定字母开头的联系人列表。这可以通过自定义`UITableViewHeaderFooterView`实现: ```swift...

    ios-UITableView的cell移动位置.zip

    6. **处理section**:如果列表包含多个section,还需要考虑section间的cell移动,这将涉及到数据源中section的管理。 7. **处理手势冲突**:由于UITableView自身有滚动和选择等手势,可能与拖动操作冲突。需要正确...

    TableView条件筛选 iOS

    - 对于大量数据,可以考虑使用`Section Index`(侧边索引)提高查找效率。 8. **响应式设计** - 考虑到不同设备的屏幕尺寸,需要确保筛选界面在iPhone和iPad上都有良好的展示效果。 - 使用AutoLayout和Size ...

Global site tag (gtag.js) - Google Analytics