0

我有一个UITableViewCell包含一个UIImageView和两个的自定义UILabel。当我运行应用程序时,UIImageVIew显示但不显示UILabel.

这是我的代码:

视图控制器.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;
}

自定义细胞.h

@interface CustomCell : UITableViewCell

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

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

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

任何想法,为什么UIImageView显示但不显示UILabel

我正在使用 Xcode 5 并将目标 IOS 版本设置为 7。

4

1 回答 1

0

将您的UILabeland添加UIImageView到您自定义的 contentView 中UITableViewCell

于 2013-10-06T06:31:50.213 回答