UI基础之 --------- UITableView

1.UITableView 的继承  UITableView : UIScrollView

2.两种样式:1.UITableViewStylePlain     不需要分组显示 如同通讯录

                     2.UITableViewStyleGrouped    分组模式  如同微信设置

3.UITableView 需要设置两个代理  数据源   代理方法

                 数据源:UITableViewDataSource   作用:可以规定cell显示多少数据,显示什么数据 cell显示数据全靠这个。

                 代理方法:UITableViewDelegate  作用:判断cell是否被点击

4.数据源方法有哪些?

1.必选 cell有多少行

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

2.cell的显示内容

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

3.可选 cell有多少组

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;

4.每一组的组标题   和组尾描述

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;

5.cell右侧的索引

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;   //组的索引

6.



UITableView必须知道的属性

1.NSIndexPath,该类拥有两个属性section和row 

NSIndexPath:用来标识当前cell的在tableView中的位置

section:标识当前cell处于第几个section中

row : 代表在该section中的第几行。

2.常见属性

rowHeight  :统一设置行高

separatorStyle :分割线样式

separatorColor :分割线颜色

sectionHeaderHeight

sectionFooterHeight

tableHeaderView  :分组头 一般方法广告

tableFooterView :分组尾: 加载更多


cell自带的属性

imageView :自带左侧图片

textLabel :左侧上面文字

detailTextLabel : 左侧描述文字

contentView :自带的view  防止重用

backgroundView  : cell的背景view

selectedBackgroundView  :选中时的背景

selectionStyle :样式

accessoryType  : 右侧样式 箭头

accessoryView : 右侧可以放view



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值