Adding unknown number of rows to 'Static Cells' UITableView

后端 未结 7 1653
孤城傲影
孤城傲影 2020-11-28 04:07

I have a static table created in Interface Builder with 6 sections all with different amounts of rows. I now want to add a 7th section with a varying number of rows.

7条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 04:40

    I think I found a better and easier solution, with "fantom" sections or rows in IB.

    In case you know the maximum number of cells you would use in section 7(lets say 10), you should set the number of rows to 10, when you configure section 7 in IB.

    You aren't forced to use all 10 rows in section, this can be set by

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

    For example if you return 5 when section == 6(actually the 7th section), then only 5 rows will be displayed.

    I admit that's not dynamic in the absolute sense of the word, but perhaps resolves most of the cases.

提交回复
热议问题