带有unicode文本的UILabel太多了 [英] Too many UILabels with unicode text

查看:89
本文介绍了带有unicode文本的UILabel太多了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPad应用中有180 UILabels UITableViewCells 的子视图),每个应用宽155宽X 155 UILabel ,当我向下滚动 TableView 时,每个文本都包含大量的Unicode文本(阿拉伯语)挂起1秒然后保持正常滚动,这发生在用户每次滚动尝试时,这在iPAD2设备上进行测试。

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.

然而,当我将文本更改为英语(也是大量英文文本), TableView 不会挂起并正常滚动。

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

任何人都有关于如何用Unicode文本解决这个问题的想法?

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

提前非常感谢你。

编辑:

这里的代码很大,所以简而言之,我用这样的循环创建每个 UILabel [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; cellForRowAtIndexPath 方法中,然后使用框架稍后根据界面方向在同一方法中,之后我将每个 UILabel 添加到单元格中: [cell.contentView addSubView:myLabel]; 。每个单元格包含4个'UILabels',所以我总共有45个单元格,仅此而已,直接和简单的代码。

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.

推荐答案

unicode的使用不应该是问题,因为它会以与任何其他文本类似的速度呈现。

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

可能有一些问题是减慢代码速度。首先,您应该尝试使用UITableView的本机单元重用,将标签添加到UITableViewCell,然后将它们dequeueWithResusableIdentifier。您应该只在该方法返回nil时生成标签,并且您必须创建一个新的UITableViewCell(如果您已经这样做,则从原始问题中不清楚)。

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.

这篇关于带有unicode文本的UILabel太多了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆