UITableView scrolling slow, memory leak issue

后端 未结 2 431
日久生厌
日久生厌 2021-01-23 08:36

I have a UITableView and a UITableCell subclass. Each table cell has two scrollviews that each rotate a dynamic amount of labels, which ar

2条回答
  •  情话喂你
    2021-01-23 09:07

    Are you using ARC? If not, you should autorelease to

    cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]
    

    Cell objects are reused and you do not need to re-add subviews each time you change the contents. Just change the data and update the label frames if needed.

    If you have distinctly different cells, consider using separate custom cell classes. You will need to use a separate value for the reuseIdentifier.

    Also consider not creating a custom cell but just adding elements to the standard UITableViewCell. Read this about styling a cell.

提交回复
热议问题