ios tableview section的运用

一、主要是分割开来code

//返回几个section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

//设置标题  能够根据section的值来设置 第一个为0
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    return @" ";
}

//每一个section有多少个cell
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(section==0){
        return 3;
    }else{
        return 1;
    }
}
相关文章
相关标签/搜索