tableview系统cell的4种样式

这篇博客通过创建UITableViewViewController来直接讲解系统Cell的四种样式:UITableViewCellStyleDefault(基础样式)、UITableViewCellStyleValue1(左蓝右对齐)、UITableViewCellStyleValue2(右蓝左对齐)和UITableViewCellStyleSubtitle(上下两行文本)。内容详细展示了每种样式的特征,并提供了应用示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

还是老方法,直接创建tableviewController,省去一些代理的设置,直接讲解内容
不明白省略那些参考上一篇微博:
http://blog.youkuaiyun.com/lee727n/article/details/72582906

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

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


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"reuseIdentifier"];
    }
    cell.textLabel.text = @"标题";
    cell.detailTextLabel.text = @"详细内容";
    cell.imageView.image = [UIImage imageNamed:@"abc"];
    return cell;
}

4种cell的样子如下
UITableViewCellStyleDefault
// Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x)
这里写图片描述
UITableViewCellStyleValue1
// Left aligned label on left and right aligned label on right with blue text (Used in Settings)
这里写图片描述
UITableViewCellStyleValue2
// Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
这里写图片描述
UITableViewCellStyleSubtitle
// Left aligned label on top and left aligned label on bottom with gray text (Used in iPod).
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值