##一般 UITableView headerView头视图的复用
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
static NSString *IDD = @"dddd";
UITableViewHeaderFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:IDD];
if (!view) {
view = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:IDD];
}
return view
就可以实现复用headView
如果自定义了一个headView 好像就不太能用系统的
#万幸 我的自定义headView fram和系统差不多 所以
#pragma mark - tableviewDelegate
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
static NSString *IDD = @"dddd";
UITableViewHeaderFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:IDD];
if (!view) {
view = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:IDD];
if (section == 0) {
jfheadView = [JFcustomHeadView viewWithTitlaName:@"百步商城"];
jfheadView.delegate = self;
[view addSubview:jfheadView];
}
else if (section == 1) {
jfheadView = [JFcustomHeadView viewWithTitlaName:@"淘五金商城"];
jfheadView.delegate = self;
[view addSubview:jfheadView];
}
else if (section == 2) {
jfheadView = [JFcustomHeadView viewWithTitlaName:@"我的商城"];
jfheadView.delegate = self;
[view addSubview:jfheadView];
}
}
return view;
}
#直接在系统的view上添加我的自定义headView