2013-12-14 5 views
0

인터페이스 작성기를 사용하여 UITableCellView 사용자 지정을 만들려면이 자습서를 따르겠습니다. 난 UITableViewCell 사용자 정의 UITableViewCell 클래스로 xib 파일을 만들었습니다. 연결 메뉴에서 나는 사용자 정의 UITableViewCellUIImageViewrestaurantImage을 끌고, 사용자 정의 UITableViewCell의 인터페이스 빌더 파일에서사용자 정의보기가 업데이트되지 않음

@interface SearchResultCell : UITableViewCell 
@property(strong,nonatomic)IBOutlet UIImageView *restaurantImage; 
@property(strong,nonatomic)IBOutlet UILabel *restaurantName; 
@end 

을하고 restaurantName에 라벨 - 고 말했다 클래스에서 나는 있습니다.

그런 다음 내 테이블이 그려진 장소에서 나는이 작업을 수행 -

-(UITableViewCell *)tableView:(UITableView *)tableView 
     cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    SearchResultCell *cell = [self.resultTable dequeueReusableCellWithIdentifier:CellTableIdentifier]; 
    NSDictionary *rowData = self.resultsTuples[indexPath.row]; 
    NSString* restaurantTitle = rowData[@"$element"][@"Title"]; 
    cell.restaurantName.text = restaurantTitle; 
    return cell; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    UINib *nib = [UINib nibWithNibName:@"SearchResultCell" 
           bundle:nil]; 
    [self.resultTable registerNib:nib forCellReuseIdentifier:CellTableIdentifier]; 
    // Do any additional setup after loading the view. 
} 

아무것도 발생하지 않습니다 cell.restaurantName.text = restaurantTitle을하는. 그러나 cell.textLabel.text = restaurantTitle을 사용하면 효과가 있습니다.

왜 내 라벨이 업데이트되지 않습니까?

+1

클래스가 'TooviaSearchResultCell'이라고 보이지만 다른 클래스 인 SearchResultCell을 참조하고 있습니다. 너의 방법. – nhgrif

+1

IB의 셀 스타일이 "Custom"으로 설정되어 있습니까? – rdelmar

+0

죄송합니다 - 복사하여 붙여 넣기 오류 - 예, 스타일이 맞춤으로 설정되었습니다 – praks5432

답변

0

세포 사용자 지정 라벨을 보일 수있는 올바른 높이되지 않을 수 있습니다. xib에서 245 포인트의 셀을 만들었으므로 tableView : heightForRowAtIndexPath :를 구현하고 245를 반환해야합니다.

0
  1. 이 작업을 수행하고 있습니까? 코드에서 그 후

    @synthesize restaurantImage; 
    @synthesize restaurantName; 
    
  2. :

    restaurantName = [[UILabel alloc]initWithFrame:yourRestaurantNameFrame]; 
    //other attribute 
    [self.contentView addSubview:restaurantName]; 
    
관련 문제