tableView中静态cell与动态cell的混合使用
2017-03-16 本文已影响0人
小蜗牛成长记
首先记住一点:tableview的静态cell只能在tableViewController里面使用,其次记住界面设计时tableviewcontroller上会自带一个tableview,如果界面设计需要分上下两部分的情况,建议不要使用tableviewcontroller。好了,下面回归正文:
首先要设置tableview的cell为静态cell

其次:在此我是使用storyboard拖拽的tableviewcontroller,在此section-1与section-3是使用的静态cell,section-2是使用的动态cell,但是section-2也必须要先设置一个静态cell并且要给cell设置indentifier,如下图所示:

最后:tableview必须要实现这四个代理方法,否则会crash:

在此以前没有使用过tableview的这个方法,-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath;因此查了一下,这是一个行缩进的方法,但是在此为什么要用这个方法,还没弄清楚,以后有时间会继续研究,直到真的懂了,也希望知道的小伙伴可以告知一下。