3.0之后如何使用initWithStyle制作自定义TableViewCell
我正在尝试使用 initWithStyle 自定义 TableViewCell,因为它说 initWithFrame 在 3.0 后已弃用。之前 initWithFrame 一切正常。
有可用的教程或示例代码吗?谢谢。
I am trying to have custom TableViewCell with initWithStyle, since it says initWithFrame is deprecated after 3.0. Everything worked fine with initWithFrame before.
Is there any tutorials or sample code available for this? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对 UITableViewCell 进行了子类化,然后重写了 initWithStyle 方法。
msgText 是该类的 UILabel 属性,我在其他地方设置了标签的文本属性。您可以将任何您喜欢的视图添加到 self.contentView 中。当我添加文本和/或图像等内容时,我还会设置每个子视图的框架。
I have subclassed UITableViewCell then override the initWithStyle method.
msgText is a UILabel property of the class and I set the text property of the label elsewhere. You can add any views to self.contentView you like. I also set the frame of each of the subviews when I add the content like text and/or images.