自定义UITableViewCell与字幕样式 [英] Custom UITableViewCell with Subtitle style
问题描述
我使用了本指南: http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder 能够使用漂亮的背景图像创建我自己的自定义UITableViewCell在界面构建器中。但我希望单元格的样式是UITableViewCellStyleSubtitle仍然可以使用textLabel和detailTextLabel作为我的自定义单元格。我可以通过某种方式在界面构建器中设置单元格的样式吗?
I used this guide: http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder to be able to create my own custom UITableViewCell with a nice background image in interface builder. But I would like the style of the cell to be UITableViewCellStyleSubtitle to still be able to use textLabel and detailTextLabel for my custom cell. Can I in some way set the style of the cell in interface builder?
现在只使用textLabel时设置:
Now only the textLabel is set when using:
cell.textLabel.text = @"Title";
cell.detailTextLabel.text = @"Details";
此外,我使用透明图像作为背景,但textLabel具有白色背景。我可以在界面构建器中更改它吗?或者您认为我应该将自己的标签添加到界面构建器中的自定义单元格中并跳过标准textLabel和detailTextLabel?
Also I use a transparent image as background, but textLabel has white background. Can I change this in interface builder? Or do you think I should just add my own labels to the custom cell in interface builder and skip the standard textLabel and detailTextLabel?
感谢您的帮助!
推荐答案
使用选项B.要么完全使用自己的自定义单元格,要么完全使用Apple的样式单元格。尝试混合和匹配不是向前兼容的。
Use Option B. Either fully use your own custom cell, or fully use Apple's styled cell. Trying to mix and match is not forward compatible.
如果你想要一个方便的属性detailTextLabel,子类 UITableViewCell
并返回您在nib中创建的 UILabel
。给它一个不同于 detailTextLabel
的名称。
If you want a convenient property for the detailTextLabel, subclass UITableViewCell
and return the UILabel
you create in the nib. Give it a different name than detailTextLabel
.
这篇关于自定义UITableViewCell与字幕样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!