OC ui表示图积累难记方法

表视图

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

在视图滚动时调用此方法,基于UIView。

contentoffset是UIScrollView的一个属性,表示当前显示视图顶点距离frame的偏移量

contentSize 表示可显示视图的大小,大小超过了frame可以通过滚动来查看,比如frame是(0,0,320,480),contentsize是(320, 1000),那scrollView的范围就是(320, 1000),超出的部分可以通过滚动来查看下面的东西

viewController写TableViewController必须继承UITableViewDataSource, UITableViewDelegate这两个协议,而且必须实现以下俩个方法cell数量和cell的设置

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

cell的数量,需要return返回

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

cell的设置,一般都固定写法

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

cell的高度,需要return返回

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

点击cell 的方法,可以推出下一个视图,可以属性传值

- (void)setSelected:(BOOL)selected animated:(BOOL)animated

cell被选中的动画方法

图片在cell上的自适应高度公式cell的高度 cell的宽度 * 图片的高度 图片的宽度

setAccessoryType cell的辅助视图



- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

判断能不能移动

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath

tableView中每一行移动的方法


自定义cell时

UIView初始化完以后会调用- (void)layoutSubviews方法 需要先调用父类layoutSubviews

其实的self.contentView是铺在cellView上的一层,往cell上放东西都放他上面(为了防止铺在cell上东西太多导致调用混乱)



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

section区域的数量

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

section的header title的名字,就是每个区域section的名字

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

标题的高度

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

标题的设置,每个Section区域的头


- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

侧栏的titles,就像通讯录右边的ABCD。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值