UITableViewCell

来源:互联网 发布:安徽快三遗漏数据统计 编辑:程序博客网 时间:2024/05/16 01:28
1.定义每个UITableView中的cell的行高

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    // indexPath.section,根据分组进行更精确的配置

    return 90.0;

}


2.设置UITableView每个分组的Header的Title

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

    return [_arrayType objectAtIndex:section];

    

}


3.设置UITableView分组Header的高

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 30.0;

}


4.设置UITableView自定义的Header

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


    // 自定义的Header

    ViewForCellHeader *headerView=[[[ViewForCellHeader alloc] init] autorelease];

    headerView.strSectionName=[_arrayType objectAtIndex:section];

    return  [headerView view];

}


注意:2与4是互斥的。

同理原理,我们分别也对Footer进行设置。

5.设置UITableView每个分组的Footer的Title

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{

    return [_arrayType objectAtIndex:section];

    

}


6.设置UITableView分组Footer的高

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    // indexPath.section,根据分组进行更精确的配置

    return 30.0;

}


7.设置UITableView自定义的Footer

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

    // 自定义的Footer

    ViewForCellHeader *headerView=[[[ViewForCellHeader alloc] init] autorelease];

    headerView.strSectionName=[_arrayType objectAtIndex:section];

    return  [headerView view];

}


8.设置UITableView每个分组的Footer的Title

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

    return [_arrayType objectAtIndex:section];

    

}


0 0
原创粉丝点击