인터페이스 작성기를 사용하여 UITableCellView
사용자 지정을 만들려면이 자습서를 따르겠습니다. 난 UITableViewCell
사용자 정의 UITableViewCell
클래스로 xib 파일을 만들었습니다. 연결 메뉴에서 나는 사용자 정의 UITableViewCell
의 UIImageView
에 restaurantImage
을 끌고, 사용자 정의 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
을 사용하면 효과가 있습니다.
왜 내 라벨이 업데이트되지 않습니까?
클래스가 'TooviaSearchResultCell'이라고 보이지만 다른 클래스 인 SearchResultCell을 참조하고 있습니다. 너의 방법. – nhgrif
IB의 셀 스타일이 "Custom"으로 설정되어 있습니까? – rdelmar
죄송합니다 - 복사하여 붙여 넣기 오류 - 예, 스타일이 맞춤으로 설정되었습니다 – praks5432