2013-10-06 2 views
0

UITableViewCell에는 UIImageViewUILabel이 포함되어 있습니다. 앱을 실행할 때 UIImageVIew이 표시되지만 UILabel은 표시되지 않습니다.UITableViewCell 이미지가 표시되지만 텍스트가 표시되지 않습니다.

ViewController.m

-(void)viewDidLoad 
{ 
    [super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 

    self.myTableView.dataSource = self; 
    self.myTableView.delegate = self; 

    titleLabel = @[@"Kiruba",@"Kiruba",@"Kiruba",@"Kiruba"]; 
    subtitleLabel = @[@"xxx",@"xxx",@"CHN",@"CHN"]; 
} 

-(void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return titleLabel.count; 
} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellId = @"Cell"; 
    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; 
    if (cell) { 
     cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; 
    } 
    // NSLog(@"Text : %@",[titleLabel objectAtIndex:indexPath.row]); 
    cell.TitleLabel.text = [titleLabel objectAtIndex:indexPath.row]; 
    cell.SubtitleLabel.text = [subtitleLabel objectAtIndex:indexPath.row]; 
    cell.myImageView.image = [UIImage imageNamed:@"DSCN5478.JPG"] 

    return cell; 
} 

CustomCell.h : 다음 UIImageView 표시 얻을 왜

@interface CustomCell : UITableViewCell 

@property (weak, nonatomic) IBOutlet UILabel *TitleLabel; 

@property (weak, nonatomic) IBOutlet UILabel *SubtitleLabel; 

@property (weak, nonatomic) IBOutlet UIImageView *myImageView; 

어떤 생각,하지만 UILabel 여기

내 코드인가?

나는 사용자 정의 UITableViewCell의있는 contentView에 UILabelUIImageView 추가 7.

+0

이 코드가 실제 코드입니까? 'if (cell)'은'if (cell == nil)'이어야하기 때문에 의문입니다. 또는 프로토 타입 셀을 사용합니까? –

+0

@MartinR : 프로토 타입 셀을 사용 중입니다. – Kirubachari

+2

그러면 dequeueReusableCellWithIdentifier는 항상 셀을 반환하고 다음 if 문은 전혀 필요하지 않습니다. –

답변

0

으로 엑스 코드 5 및 설정 대상 IOS 버전을 사용하고 있습니다.

관련 문제