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

本文介绍了如何在 iOS 开发中使用 UITableView 进行自定义操作,包括移除分割线、设置单元格高度及创建自定义 Cell 的方法。通过具体代码示例展示了如何实现这些功能。


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


转载于:https://my.oschina.net/bingshanguxue/blog/360415

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值