不使用不推荐使用的方法 initWithFrame:reuseIdentifier 的 UITableViewCell

编程入门 行业动态 更新时间:2024-10-28 21:30:02
本文介绍了不使用不推荐使用的方法 initWithFrame:reuseIdentifier 的 UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已阅读洛伦的文章 为 UITableViewCell 绘制自己的内容.但是,他使用了不推荐使用的方法:initWithFrame:reuseIdentifier: 在 UITableViewCell 上已被弃用.

I have read Loren's article on drawing your own content for UITableViewCell. However, he is using a deprecated method: initWithFrame:reuseIdentifier: is deprecated on UITableViewCell.

如何在不使用 initWithFrame:reuseIdentifier 的情况下让他的示例工作?

How do you get his example to work without using initWithFrame:reuseIdentifier?

推荐答案

只需将 initWithFrame:reuseIdentifier: 替换为以下内容.

just had to replace initWithFrame:reuseIdentifier: with the following.

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { // you might want to add the UIView to [self contentView] // so that in edit's the cell's content will be automatically adjusted. ABTableViewCellView *myUIView = [[ABTableViewCellView alloc] initWithFrame:CGRectZero]; myUIView.opaque = YES; contentViewForCell = myUIView; [self addSubview:myUIView]; [myUIView release]; } return self; }

此外,苹果有一个 Loren 指出的例子,但他们使用 initWithStyle:reuseIdentifier:

Also, apple has an example as Loren points out but they use initWithStyle:reuseIdentifier:

developer.apple/iphone/library/samplecode/TableViewSuite/Introduction/Intro.html

更多推荐

不使用不推荐使用的方法 initWithFrame:reuseIdentifier 的 UITableViewCell

本文发布于:2023-10-10 23:01:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1480004.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:推荐使用   方法   initWithFrame   reuseIdentifier   UITableViewCell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!