简体   繁体   中英

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

Can you help me understandand/fix the error below. I don't understand as CustomCellView is a subclass of UItableViewCell . The code gets compiled but the warning is still there:

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

I got the 2nd line below hightlighted:

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

you need to type cast to your cell

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM