iOS-用自定义的xib做TableView中的cell
2018-07-19 本文已影响0人
HeavensLife
1.首先,建立一个.xib文件,并拖拽TableViewCell控件,
![](https://img.haomeiwen.com/i13032787/413bb952732185df.png)
2.然后根据自己的需求布局,
![](https://img.haomeiwen.com/i13032787/486c557d5e8095aa.png)
3.再新建TableViewCell文件。
![](https://img.haomeiwen.com/i13032787/c1c81fb78a84dba4.png)
4.将xib与新建的tableViewCell进行关联。
![](https://img.haomeiwen.com/i13032787/58af460b5e22c445.png)
5.在TableViewCell.h中添加Label标签。
![](https://img.haomeiwen.com/i13032787/f5ad382bed0d6487.png)
6.然后,在TabelView中设置cell。
![](https://img.haomeiwen.com/i13032787/250af6d2e6d8eb7a.png)
7.其中的@“cellTest”是.xib的文件名。最后在TableView中写如下该方法,会自动适配你定义的xib高度。
![](https://img.haomeiwen.com/i13032787/640ce91bdf576dfa.png)
这样就可以在你的TableView中使用自己写的xib做的cell了。
下一篇:iOS-自定义xib做cell时的点击跳转问题