I am creating a custom Table by designing my own UITableViewCell
in Xcode and loading it in cellForRowAtIndexPath
. I am facing scrolling problems; the table scrolls really slow and not smooth at all. In each cell I have:
- Either 2 or 3
UIImageView
where the 3rd one is added dynamically when needed - 1
UILabel
- 1
UITextView
- Some cells might have 2
UIButton
, some 1UIButton
, and the majority no buttons at all - In some cells I might add an overlay
UIView
The sizes of the image views, text view, and buttons are different in every cell. To prevent calculating the sizes every time the table is scrolled I load all the sizes in viewWillAppear
and store them in an array, and inside cellForRowAtIndexPath
I only load the sizes from the array and set them to the desired objects.
I tried all the ideas that I found on the web (like loading the images in the body of if(cell == nil)
as shown here, or not de-queue the cells...) but nothing solved my problem.
On the other hand I notice that the chatting app WhatsApp uses similar amount of items per cell (example when the user receives an image, there are 2 buttons View and Forward, the image thumbnail, a check mark image next to the thumbnail, a date label, a bubble image behind the thumbnail...) but the scrolling there is very smooth.
My scrolling is slow even if I have 10 cells in the table only. Here are my questions:
- Am I doing something dramatically wrong that I am not noticing?
- Is there a limit for the number of items that should be added to a custom cell to prevent slow scrolling?
- Is there a way to detect the reason of slow scrolling by using something like Product->Profile in Xcode?
- Can anyone suggest a solution for my problem?
Many thanks in advance.