我应该使用什么电话代替这种弃用的方法?

时间:2012-01-31 07:02:30

标签: iphone ios cocoa-touch uitableview deprecated

我有一个 UITableViewController ,可以创建动态可调整大小的单元格。单元格根据文本内容和字体大小更改单元格的大小。 (这里有一个提示。)

它使用了对以下方法的调用:

cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 

我无法确定使用哪种方法并保留我的功能。 Apple文档中没有引用。

我怎么解决这个问题?

3 个答案:

答案 0 :(得分:2)

The documentation具体说明:

  

在iOS 3.0中已弃用。请改用initWithStyle:reuseIdentifier:

答案 1 :(得分:1)

尝试这样的事情。

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Standard"];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Standard"] autorelease];
}

答案 2 :(得分:1)

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];