问题描述
出于性能原因,我在自定义视图中绘制UITableViewCell的字符串,该视图覆盖其drawRect方法,使用NSString:drawInRect直接在视图矩形中绘制字符串。这类似于Apple的TableViewSuite示例5-CustomTableViewCell。
For performance reasons, I draw the strings for my UITableViewCell in a custom view that overrides its drawRect method to draw strings directly in the view rectangle using NSString:drawInRect. This is similar to Apple's TableViewSuite Example 5-CustomTableViewCell.
然而,当我在单元格上调用setEditing以调出删除按钮时,视图最终会出现挤压外观动画完成后。为了演示这一点,请在上面提到的CustomTableViewCell示例上调用setEditing:YES并观察失真。有什么方法可以解决这个问题,还是应该恢复使用UILabels作为我的文本?
However, when I invoke setEditing on the cell to bring up the delete button, the view ends up with a squeezed appearance after the animation completes. To demonstrate this, invoke setEditing:YES on the CustomTableViewCell example mentioned above and observe the distortion. Is there any way around this or should I just revert back to using UILabels for my text?
推荐答案
我遇到了类似的问题UITableViewCell中的UIView。我通过将UIView的 contentMode
更改为 UIViewContentModeLeft
来解决了这个问题。 (我用写了截图。)
I had a similar problem with a UIView inside a UITableViewCell. I solved it by changing the UIView's contentMode
to UIViewContentModeLeft
. (I wrote it up here, with screenshots.)
这篇关于如何使自定义绘制的UITableViewCell正确调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!