利用UITableView实现左右两栏滚动的关联【附Demo】

来源:互联网 发布:阿里云 共享计算型 编辑:程序博客网 时间:2024/06/04 23:30

实现功能

左栏为大项列表,右栏为没项目的子列表。实现了选择左栏,右栏滚动到对应列表;滚动右栏,左栏大项的选中状态对应改变。
代码见demo,这里简单介绍几个主要的方法。

主要方法及简析

//section的header的标题,随着UITableView的滚动,总会有一个驻留在UITableView的顶端。- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{}//header消失时事件的监听,相应的还有其它几个代理方法,- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{}//控制UITableView的滚动,滚动到特定的区域- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;//重新加载UITableView的特定Cell- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation NS_AVAILABLE_IOS(3_0);


运行效果图


Demo下载地址

http://download.csdn.net/download/u011439689/8344571





0 0
原创粉丝点击