我正在处理这段代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:CGRectZero reuseIdentifier:nil] autorelease];
}
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
并首先更换
initWithFrame:
带
initWithStyle:
上面的,因为我收到initWithFrame:reuseIdentifier deprecated
错误。
但是,现在我收到了一个新错误:
Sending 'const CGRect' (aka 'const struct CGRect') to parameter of incompatible type 'UITableViewCellStyle' (aka 'enum UITableViewCellStyle').
此错误主要针对上面CGRectZero
中的initWithStyle:CGRectZero
。
我已经搜索过,无法解决这个问题。有人知道如何解决这个问题吗? 提前致谢! :)
答案 0 :(得分:0)
style
参数必须是UITableViewCellStyle
enumeration values之一:
typedef enum : NSInteger {
UITableViewCellStyleDefault ,
UITableViewCellStyleValue1 ,
UITableViewCellStyleValue2 ,
UITableViewCellStyleSubtitle
} UITableViewCellStyle;
如果仔细观察,您会发现CGRectZero
不在列表中。通常,当您更改语句以发送不同的消息时,您应该需要更改作为消息参数传递的值。