2012-10-30 8 views
0

UITableview 용 사용자 정의 셀을 작성하려고합니다. 내가 촬영 한 접근 방식은uitableviewcell을 하위 클래스로 만들 때 예외가 발생했습니다.

  • UITableViewCell을 서브 클래스 및 UI 구성 요소 (레이블, 이미지 등)

  • 펜촉을 만들어 내 사용자 정의 클래스에 해당 클래스를 변경하기위한 회원이 내 자신의 사용자 정의 클래스를 생성 . 여기

내 클래스의 코드

헤더 파일

#import <UIKit/UIKit.h> 

@interface ActivePoolViewCustomCell : UITableViewCell{ 
    UILabel* lblDate; 
} 
@property (nonatomic, retain)IBOutlet UILabel* lblDate; 
@end 

나는 펜촉을 생성하고 해당 클래스를 변경 다음

#import "ActivePoolViewCustomCell.h" 

@implementation ActivePoolViewCustomCell 
@synthesize lblDate; 
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 
     // Initialization code 
    } 
    return self; 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 

@end 

구현 파일 ActivePoolViewCu stomCell에 연결하고 UILabel을 lblDate 콘센트에 연결합니다.

이제 I 직면하는 문제이고, I는

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    static NSString *CellIdentifier = @"ActivePoolCell"; 

    ActivePoolViewCustomCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     // Load the top-level objects from the custom cell XIB. 
     NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ActivePoolViewCustomCell" owner:self options:nil]; 
     // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain). 
     cell = (ActivePoolViewCustomCell*)[topLevelObjects objectAtIndex:0]; 
     cell.lblDate.text = @"abcd"; 
    } 
    return cell; 
} 

난 다음 오류를

2012년 10월 30일 18 얻을 펜촉로드 다음 코드를 실행할 때 : 13 : 56.451 CDA에게 [ 637 : f803] ** 캐치되지 않은 예외 'NSUnknownKeyException'으로 인해 앱 종료 중 '이유 :'[setValue : forUndefinedKey :] :이 클래스는 키 lblDate에 대해 키 값을 코딩하지 않습니다. '

많은 어려움 끝에이 문제의 원인을 파악할 수 없습니다. 여기에 어떤 문제가 있습니까? 또는 개념 자체가 잘못 되었습니까?

답변

0

마침내 그것을 분류했습니다. 문제는 ActivePoolViewCustomCell 클래스를 셀 자체에 적용해야하는 내 사용자 정의 셀 펜촉의 파일 소유자에 적용하는 것이 었습니다.

이 비디오는 그것을 해결하기 위해 나를 도와

http://www.youtube.com/watch?v=d_kO-J3DYvc

관련 문제