2011-07-31 2 views
1

를 호출하고 여기에 내 코드에서이 방법은 없습니다있는 UITableViewCell :내가 프로그래밍 방식 (NO XIB) 내있는 UITableViewCell을 만들어 initWithFrame

문제는 나는 그것이 initWithFrame를 호출 볼 수 없다는 것입니다

가 호출되고

- (id) initWithFrame: (CGRect)frame { 
    self = [super initWithFrame: frame]; 
    if (self) { 
     NSLog(@"CALLING INIT WITH FRAME"); 

     self.like_img = [[[UIImageView alloc] initWithFrame:CGRectMake(5, 75, 30, 30)] autorelease]; 
     [self.contentView addSubview: self.like_img]; 

     self.comment_img = [[[UIImageView alloc] initWithFrame:CGRectMake(5, 110, 30, 30)] autorelease]; 
     [self.contentView addSubview: self.comment_img]; 

     self.type_img = [[[UIImageView alloc] initWithFrame:CGRectMake(5, 40, 30, 30)] autorelease]; 
     [self.contentView addSubview:self.type_img]; 

     self.avatar = [[[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 30, 30)] autorelease]; 
     [self.contentView addSubview:self.avatar]; 

     self.post = [[[UITextView alloc] initWithFrame:CGRectMake(40, 40, 650, 100)] autorelease]; 
     [self.contentView addSubview:self.post]; 

     self.post_title= [[[UILabel alloc] initWithFrame:CGRectMake(40, 20, 650, 50)] autorelease]; 
     [self.contentView addSubview:self.post_title]; 

     self.post_detail = [[[UILabel alloc] initWithFrame:CGRectMake(40, 10, 650, 20)] autorelease]; 
     [self.contentView addSubview:self.post_detail]; 

    } 

    NSLog(@"NOT MY SELF"); 
    return self; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"FTPostCell"; 

    FTPostCell *cell = (FTPostCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     NSLog(@"INITIALIZING CELL"); 
     cell = [[[FTPostCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    //snip some code here 
    return cell; 
} 
, 왜 이거 야? reuseIdentifier :

답변

7

initWithFrame는 당신이

initWithFrame 호출하기 때문에 호출되지 않습니다 그러므로 내가 무엇을보고하고하는 것은 그냥 빈 셀 ...

교체

- (id) initWithFrame: (CGRect)frame { 
    self = [super initWithFrame: frame]; 

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier { 
    self = [super initWithFrame: frame reuseIdentifier:reuseIdentifier]; 

initWithFrame : reuseIdentifier는 사용되지 않는 메소드이므로 initWithStyle : reuseIdentifier를 대신 사용해야합니다.

+0

어떻게 해결할 수 있습니까? – adit

+0

내 답변 편집 –