UITableView scrolling slow, memory leak issue

后端 未结 2 430
日久生厌
日久生厌 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 08:49

    The first thing you could do is try to reuse UILabels in createPopularLinkLabels. Right now, you are just removing them before adding more.

    But if the number of popular links is not the same in all the cells, then you will have to remove the remaining ones or hide them and there will be no way to avoid memory allocations.

    A better solution would be to insert a custom UIView inside your scroll view and draw all the texts manually instead of creating tons of subviews.

    Hope this helps, Thomas

提交回复
热议问题