【问题标题】:Incompatible pointer type initializing 'CustomCellView *' with an expression of type UItableViewCell使用 UItableViewCell 类型的表达式初始化“CustomCellView *”的不兼容指针类型
【发布时间】:2011-09-10 15:38:27
【问题描述】:

您能帮我理解和/修复以下错误吗?我不明白CustomCellViewUItableViewCell 的子类。代码已编译,但警告仍然存在:

Incompatible pointer type initializing 'CustomCellView *' with an expression of type `UItableViewCell`

我突出显示了下面的第二行:

static NSString *CellIdentifier = @"CustomCell";
CustomCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

【问题讨论】:

    标签: ios iphone uitableview ios4


    【解决方案1】:
    static NSString *CellIdentifier = @"CustomCell";
    CustomCellView *cell =(CustomCellView*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    

    您需要将类型转换为您的单元格

    【讨论】:

      【解决方案2】:

      对于下面的自定义单元格,代码在给定框架下也可以正常工作..

        CustomCell *cell= [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];
      

      【讨论】:

        【解决方案3】:
        static NSString *CellIdentifier = @"CustomCell";
        CustomCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
        

        【讨论】:

        • 这个答案出现在低质量审查队列中,大概是因为您没有提供任何代码解释。如果此代码回答了问题,请考虑在答案中添加一些解释代码的文本。这样一来,您就更有可能获得更多支持,并帮助提问者学习新知识。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-04
        • 2020-11-17
        • 1970-01-01
        相关资源
        最近更新 更多