UITableViewStylePlain实现分组效果

1.初始化UITableView
UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.sectionHeaderHeight = 10;
    tableView.sectionFooterHeight = 10;
    [self.view addSubview:tableView];

2.实现数据源UITableViewDataSource中的两个方法
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return @"sectionHeader";
}
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
    return @"sectionFooter";
}

 

posted on 2015-11-12 11:17  rgshio  阅读(504)  评论(0编辑  收藏  举报

导航