ios - 如何提高具有过多 UITextView 的 UITableViewCell 的性能?

标签 ios uitextview uitableview

我有一个包含太多 UITextView 的 UITableViewCell,而且我的性能一直很差。

我想绘制文本,当用户点击文本尝试编辑时,将一个真正的 UITextView 放在那里。

我该如何实现?

最佳答案

iOS Developer Library你有一个名为 TableViewSuite 的例子,这里有一些关于如何实现 UITableView 的示例,最后一个示例(编号 5)是实现具有性能的 UITableView 的最佳方法,因此我建议您查看此示例。

TableViewSuite 项目说明:

This sample shows how to use UITableView through a progression of increasingly advanced applications that display information about time zones.

When implementing a table view cell, there's a tension between optimal scrolling performance and optimal edit/reordering performance. You should typically use subviews in the cell's content view.

When you have an edit or reordering control, using subviews makes the implementation easier, and the animations perform better because UIKit doesn't have to redraw during animations.

Subviews have two costs:

1) Initialization. This can be largely mitigated by reusing table cells. 2) Compositing. This can be largely mitigated by making the views opaque. Often, one translucent subview is fine, but more than one frequently causes frame drops while scrolling.

If the content is complex, however (more than about three subviews), scrolling performance may suffer. If this becomes a problem, you can instead draw directly in a subview of the table view cell's content view.

The fifth example is an extension of the fourth. It displays even more information about each time zone, such as the time and relative day in that time zone. Its shows how you can create a custom table view cell that contains a custom view that draws its content in -drawRect:.

关于ios - 如何提高具有过多 UITextView 的 UITableViewCell 的性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8045380/

相关文章:

iphone - 更改 UITableview 中按下的特定按钮的图像

ios - UITableView 以编程方式未显示

iphone - 仅当用户下拉表格时才显示搜索栏

objective-c - UITextView,如何删除返回键 :linefeed?

ios - 静态更改文本字段的高度时出现意外行为

ios - coreplot Xaxis 起始值 iOS 7

ios - Objective-C:在核心数据中设置 bool 值

iphone - 如何检测我的 UITextView 何时被编辑然后调用操作?

新行中 ScrollView 插入符号错位的 iOS TextView

ios - uiscrollview framesize iphone 4inc 和 3.5 inc