UITableview HeaderView重新加载

时间:2014-06-27 07:47:41

标签: ios iphone uitableview

我创建了Dropdown Tableview,包含多个部分&每个部分作为一个标题视图。点击标题视图中的按钮,我在该部分插入一行&在从该部分删除行时点击相同的按钮。

从该部分删除行。出列的Headerview正在从自定义视图更改为本机视图。

代码:

[self.rTable registerClass:[headerCell class] forHeaderFooterViewReuseIdentifier:@"cellHeader"];


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{


headerCell *detailView = nil;

       detailView = (headerCell *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:@"cellHeader"];

 return detailView;

}

按钮操作功能:

-(void)detailViewButtonSelectedAtIndex:(int)index;
{
    if(selectedSection != -1){

        previousSelected = selectedSection;

        [self.rTable beginUpdates];

        [self.rTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:previousSelected]] withRowAnimation:UITableViewRowAnimationFade];

        [self.rTable endUpdates];


        selectedSection = -1;

        headerCell *view = (headerCell *)[self.routeTable headerViewForSection:previousSelected];

        [view.routeCell.detailButton setImage:[UIImage imageNamed:@"more"] forState:UIControlStateNormal];

    }

    if(previousSelected != index){

        selectedSection = index;

        [self.rTable beginUpdates];

        [self.rTable insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:selectedSection]] withRowAnimation:UITableViewRowAnimationMiddle];

        [self.rTable endUpdates];

        previousSelected = -1;



    }else{
        previousSelected = -1;
    }


}

enter image description here

enter image description here

0 个答案:

没有答案