首页 > 移动平台 > 详细

iOS 在TableView的Cell之间设置空白间隔空间

时间:2014-08-12 22:08:04      阅读:619      评论:0      收藏:0      [点我收藏+]

1.设置section的数目,即是你有多少个cell

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{
    return 3; // in your case, there are 3 cells
}

2.对于每个section返回一个cell

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

3.设置cell之间headerview的高度

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10.; // you can have your own choice, of course
}

4.设置headerview的颜色

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc] init];
    headerView.backgroundColor = [UIColor clearColor];
    return headerView;
}

注意:需要使用 indexpath.section 来获得index,而不是用 indexpath.row

cell.textLabel.text=[NSString stringWithFormat:@"%@",[array objectAtIndex:indexPath.section]];
翻译整理自:

http://stackoverflow.com/questions/7189523/how-to-give-space-between-two-cells-in-tableview

iOS 在TableView的Cell之间设置空白间隔空间,布布扣,bubuko.com

iOS 在TableView的Cell之间设置空白间隔空间

原文:http://blog.csdn.net/willyang519/article/details/38521057

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!