initWithFrame - 尝试与initWithStyle交换 - 发生错误

时间:2012-12-01 13:09:29

标签: iphone objective-c ios xcode

我有一段代码使用旧的折旧方法;

cell1 = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:kLastCellIdentifier] autorelease];

我尝试将initWithFrame部分替换为initWithStyle

cell1 = [[[CustomCell alloc] initWithStyle:CGRectZero reuseIdentifier:kLastCellIdentifier] autorelease];

但是这不起作用,并给出了新的错误

“没有可行的'const CGRect'转换为'UITableViewCellStyle'又名'int'”

我想知道是否有人可以帮助我更换代码行,使其适合新操作系统而不会出错。

亲切的问候,

克里斯

1 个答案:

答案 0 :(得分:0)

对于ios 6,你不传递矩形而是传递样式。

一个Style不是rect,而是一个uitableviewcellstyle枚举值

typedef enum {
   UITableViewCellStyleDefault,
   UITableViewCellStyleValue1,
   UITableViewCellStyleValue2,
   UITableViewCellStyleSubtitle
} UITableViewCellStyle;

使用例如默认

UITableViewCellStyleDefault