0

If I have a UITableView with each cell having a different layout. For example, cell 1 has one text field, cell two has two text fields and so on, in this case height of tableview cell varies based on how many text fields it has one below the other. For this specific scenario, will I be able to make use of reuseIndetifier and reuse the cell.

Is tableView reuseIdentifier useful only when layout of each cell is same? Or can I still reuse cells by making use of single identifier but adding textfields in cellForRowAtIndexPath dynamically?

4

1 回答 1

0

我试验了一下。我可以通过使用带有空模板/空白单元格的单元格来对单元格进行一些基本的重用。但在 cellForRowAtIndexPath 中,我可以动态创建文本字段并添加。这工作得很好,允许我添加需要添加到 TableView 单元格的尽可能多的视图。我正在使用空白单元格,它将在滚动时重复使用。但是,我不确定当我创建 UI 元素并将其动态添加到 cellForRowAtIndexPath 中的单元格时会对性能产生影响。有什么想法吗?

于 2015-03-04T07:39:46.773 回答