Too many UILabels with unicode text

I have 180 UILabels (subviews of UITableViewCells ) in an iPad app with a width of 155 X 155 for each UILabel , and each of them contains a lot of Unicode text (Arabic), when I scroll down the TableView it hangs for 1 second, and then continues to scroll in normal mode, this happens with every attempt to scroll the user, and this is checked on the iPAD2 device.

however, when I changed the text to English (also a large amount of text in English), the TableView does not freeze and does not scroll normally.

Has anyone figured out how to solve this problem using text in Unicode?

Thank you so much in advance.

EDIT:

the code here is very large, so, in short, I create each UILabel using a loop as follows: [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; in cellForRowAtIndexPath , then play with the frame later in the same method in accordance with the orientation of the interface, after which I add each UILabel to the cell as follows: [cell.contentView addSubView:myLabel]; . each cell contains 4 of these "UILabels", so I have a total of 45 cells, no more, direct and simple code.

+6
source share
2 answers

Using unicode should not be a problem here, as it will display at the same speed for any other text.

There may be a few issues that slow down your code. First of all, you should try to reuse UITableView cells, add labels to UITableViewCell, and then dequeueWithResusableIdentifier them. You should only generate your labels when this method returns nil, and you need to create a new UITableViewCell (it is not clear from the original question if you already do this).

One more thing you can do after this is to make sure that many of your views are opaque in order to speed up the layout. Tools include the ability to tint opaque representations to make it easier.

+1
source

There are many ways to optimize your code:

Make sure your application is not leaking. The right issue of labels. Use cell reuse. I don't know if you use it or not. Because every time you scroll your delegate method cellForRowAtIndexPath is called.

If you are unsure about reuse, try this link.

0
source

Source: https://habr.com/ru/post/912298/


All Articles