Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many UILabels with unicode text

I have 180 UILabels (subviews of UITableViewCells) in an iPad app with 155 width X 155 height for each UILabel, and each one contains a big amount of Unicode text (Arabic language), when I scroll down the TableView it hangs for 1 second and then keeps scrolling normally, this happens with every scroll attempt by the user and this is tested on iPAD2 device.

however, when I changed the text to English language (also big amount of English text), the TableView does not hang and scrolls normally.

anyone got an idea on how to solve this issue with Unicode text ?

thank you so much in advance.

EDIT:

the code is large to fit here, so in brief, I create each UILabel with a loop like this: [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; in cellForRowAtIndexPath method, then play with the frame later in the same method according to interface orientation, after that I add each UILabel to the cell like this: [cell.contentView addSubView:myLabel]; . each cell contains 4 of these 'UILabels', so I have a total of 45 cells, nothing more, straight forward and simple code.

like image 713
JAHelia Avatar asked Apr 03 '12 08:04

JAHelia


1 Answers

The use of unicode shouldn't be the problem here, as it will render at similar speeds to any other text.

There are possibly a few issues that are slowing down your code. First of all, you should attempt to use UITableView's native cell reuse, add the labels to the UITableViewCell and then dequeueWithResusableIdentifier them. You should only generate your labels when that method returns nil and you have to create a new UITableViewCell (it's unclear from the original question if you do this already).

One other thing you can do after this to make sure as many of your views are opaque as possible to speed up compositing. Instruments includes an option to tint non-opaque views to make this easier.

like image 136
cobbal Avatar answered Oct 28 '22 03:10

cobbal