Incompatible pointer type initializing 'Custom

2020-05-31 05:12发布

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];

3条回答
Summer. ? 凉城
2楼-- · 2020-05-31 05:45
static NSString *CellIdentifier = @"CustomCell";
CustomCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
查看更多
别忘想泡老子
3楼-- · 2020-05-31 05:50

For custom cell below code is also working fine with given frame..

  CustomCell *cell= [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];
查看更多
迷人小祖宗
4楼-- · 2020-05-31 06:00
static NSString *CellIdentifier = @"CustomCell";
CustomCellView *cell =(CustomCellView*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

you need to type cast to your cell

查看更多
登录 后发表回答