2011-04-27 4 views
0

XIB (아울렛 설정 사용)에 정의 된 UITableViewCell과 'CustomTableViewCell'로 설정된 사용자 정의 클래스가 있습니다. .? 지금 그러나 내가보기를 다시 정의 할 필요가이게 가능하지 같은 XIB를 사용 (그리고하고자하는 'SubclassCustomTableViewCell'와 'CustomTableViewCell'를 서브 클래 싱 찾고 있어요 내가 현재 가지고 :서브 클래 싱을 사용하는 XIB 백업 뷰

+ (SubclassCustomTableViewCell *)create 
{ 
    // Create undefined cell. 
    id cell = nil; 

    // Iterate over NIB and find a matching class. 
    NSBundle *bundle = [NSBundle mainBundle]; 
    NSArray *cells = [bundle loadNibNamed:@"CustomTableViewCell" owner:nil options:nil]; 
    for (cell in cells) if ([cell isKindOfClass:[self class]]) break; 

    // Return cell. 
    return cell; 
} 

하지만 그것은 부모 아무것도하지만 돌아 가야 할 알아낼 수 없습니다.

답변

-1
+ (SubclassCustomTableViewCell *)create 
{ 
    // Create undefined cell. 
    id cell = nil; 

    // Iterate over NIB and find a matching class. 
    NSBundle *bundle = [NSBundle mainBundle]; 
    NSArray *cells = [bundle loadNibNamed:@"CustomTableViewCell" owner:nil options:nil]; 
    for (cell in cells) if ([cell isKindOfClass:[self class]]) return cell; //change this 

    // Return cell. 
    return nil; //change this 
} 

당신이 + (SubclassCustomTableViewCell *)create가 정의된다 말해 수있는 클래스

+0

그것은이 서브 클래스에 정의되어 있습니다. 저는 ' 잠재적으로 nil을 반환하는 호출을 변경하는 것이 어떻게 도움이되는지 확실하지 않습니다 ... 나는 그것을 r에 원합니다. 테이블보기 셀을 eturn하면 ... –

+0

예. 도움이되지 않을 것입니다. 그러나 사용자 정의 셀 또는 nil 중 하나를 반환합니다 ... 부모 셀을 반환하지 않습니다. for 루프에'return cell; '을 추가했습니다. 모든 ur 클래스를 넣으십시오. –

+0

하지만 XIB 파일에는 부모 셀이 클래스로 설정되어 있습니다. 이것이 자식에서 실행된다면 아무 것도 반환하지 않을 것입니다 ... –

관련 문제