IOS 学习笔记 —— tableView 使用详解(一)


1 去除分割线

//去除分割线
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

2 高度设置

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
    //自定义高度
//    return 110;
}

3 自定义Cell,后面会详细列出如何自定义cell,由于时间关系,这里暂时给出使用方法,如下:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //MyCell是自己定义的Cell类
    MyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];
    if (!cell) {
        NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil];
        for (NSObject *o in objects) {
            if ([o isKindOfClass:[MyCell class]]) {
                cell = (MyCell *)o;
                break;
            }
        }
    }
    
    //Configure you cell
    //...
    
    return cell;
}




3


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。