二级联动,可以左侧是一个tabview右侧也是一个tabview,也可以左侧一排按钮,右侧tabview,点击左侧,刷新右侧数据,这一步很简单,我当时不理解的是右侧数据滑动,左侧怎么刷新呢,这需要考虑到tabview的加载方式是动态的,也就是说,当新的数据在右侧tabview加载的时候,比如一个新的section加载的时候,一定会走这个方法:
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (tableView.tag == 21) {
if (isScrollSetSelect == YES) {
[leftScrollView setSelectButtonWithIndexPathSection:section];
}
return [self viewForHeaderView:section];
}else{
return nil;
}
}
/实际需要会修改
-(UIView*)viewForHeaderView:(NSInteger)parama{
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 32)];
label.backgroundColor = [UIColor grayColor];
if (leftDataSource.count != 0) {
label.text = leftDataSource[parama];
// [NSString stringWithFormat:@"第%ld组",(long)parama];
}
return label;
}
//
// LeftSelectScroll.h
// YiLeHelp
//
// Created by ChenYi on 15/11/14.
// Copyright © 2015年 JC. All rights reserved.
//
//尺寸定义
#define kScreenWidth [UIScreen mainScreen].bounds.size.width//屏幕的宽度
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height//屏幕的高度
#define kNav_H kScreenHeight > 668 ? 86 : 64//屏幕的高度
#define kTabbar_H kScreenHeight > 668 ? 59 : 49//屏幕的高度
#import <UIKit/UIKit.h>
/*
@protocol LeftSelectScrollDataSource <NSObject>
- (NSInteger)numberOfRowsInSection;
- (UIButton*)viewForRowAtIndexPath:(NSInteger *)indexPath;
@end
*/
@protocol LeftSelectScrollDelegate <NSObject>
-(void)clickLeftSelectScrollButton:(NSInteger)indexPath;
@end
@interface LeftSelectScroll : UIScrollView
@property(nonatomic,strong)NSArray *leftSelectArray;
@property (nonatomic,strong)id<LeftSelectScrollDelegate>leftSelectDelegate;
-(void)setLeftSelectArray:(NSArray *)leftSelectArray;
-(void)setSelectButtonWithIndexPathSection:(NSInteger)indexPathSection;
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
@end
// 版权属于原作者
// http://code4app.com (cn) http://code4app.net (en)
// 发布代码于最专业的源码分享网站