UITableViewCell中的内容未显示

Arn*_*out 7 objective-c uitableview ios

我遇到麻烦了UITableViewCell.

我的故事板中有一个视图控制器,它连接到我的视图控制器MainViewController.它包含UITableViewCell3个标签.在UITableViewCell被连接到类MTTableViewCell.

// MTTableViewCell.h

#import <UIKit/UIKit.h>

@interface MTTableViewCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *mainLabel;
@property (strong, nonatomic) IBOutlet UILabel *statusLabel;

@end

// MTTableViewCell.m

#import "MTTableViewCell.h"

@implementation MTTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

// MainViewController.m

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

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

    MTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[MTTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }        

    NSString *namecell = @"namecell";
    NSString *statuscell = @"statuscell";           
    [cell.mainLabel setText:namecell];
    [cell.statusLabel setText:statuscell];        

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

问题是当我运行时没有显示任何内容MainViewController.我错过了什么?我没有得到任何错误,只是一个空白的记录,有1个空白记录.

Tho*_*enC 2

查看您的界面生成器 - 您应该没有“连接”您的自定义单元格,您应该将其设置为“文件所有者”,因为您实现了视图,而不是想设置委托。也许这个提示有帮助?