使用auto layout 实现cell适配

来源:互联网 发布:vb中sgn是什么意思 编辑:程序博客网 时间:2024/05/24 06:15

使用auto layout实现cell适配

1.    新建Cocoa Touch Class文件 ----->继承(Subclass of:UITableViewCell并创建  xib文件(勾选 Also create XIB file)

2.    打开新建的.xib文件设置cell组件的indetifier名称(我设置为:cell

并向窗体拖入组件(这里演示用Label)调整好组件的位置及大小Label注意设置行数默认为1

3.    label进行与父窗体相对位置的设置


4.    在新建的TableViewCell.h文件中创建Label对象并与label关联     

                                                                            

5.    TavleViewControler.m  文件中通过  “-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath”   “- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath ” 方法 设置Cell高度及内容


0 0
原创粉丝点击