2011-09-10 5 views
18

아래 오류를 이해하고 해결할 수 있습니까? CustomCellViewUItableViewCell의 하위 클래스이므로 이해가되지 않습니다. UItableViewCell 유형의 표현식을 사용하여 'CustomCellView *'를 초기화하는 호환되지 않는 포인터 유형

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

내가 강조 표시된 아래의 2 라인을 가지고 : 코드는 컴파일하지만 경고가 아직 도착

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

답변

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

당신이 당신의 셀에 캐스팅 입력 할 필요가

-1

아래 사용자 정의 셀의 경우 코드도 주어진 프레임에서 잘 작동합니다 ..

CustomCell *cell= [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease]; 
0
static NSString *CellIdentifier = @"CustomCell"; 
CustomCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
+0

코드에 대한 설명을 제공하지 않아서이 답변이 저품각 검토 ​​대기열에 표시되었습니다. 이 코드가 질문에 대답하는 경우 대답에 코드를 설명하는 텍스트를 추가하는 것을 고려하십시오. 이렇게하면 더 많은 상향 회선을 얻을 확률이 높아지고 질문자가 새로운 것을 배울 수 있습니다. – brandonscript

관련 문제