Ios 自定义TableView单元格在我的TableView中显示为白色和空

Ios 自定义TableView单元格在我的TableView中显示为白色和空,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我已经创建了一个名为OptionsTableViewCell的自定义TableViewCell类和一个名为WPOptionsTableViewController的自定义TableViewController类。细胞总是空的,白色的。以下是我迄今为止所做的工作: AppDelegate.m: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOp

我已经创建了一个名为OptionsTableViewCell的自定义TableViewCell类和一个名为WPOptionsTableViewController的自定义TableViewController类。细胞总是空的,白色的。以下是我迄今为止所做的工作:

AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds] ];
     WPOptionsViewController *vc = [[WPOptionsViewController alloc] init]
     UITableView *view = vc.tableView;
     [view registerClass:[OptionsTableViewCell class] forCellReuseIdentifier:@"OptionsTableViewCell"];

     self.window.rootViewController = vc;
     [self.window makeKeyAndVisible];
     return YES;
}
选项TableViewCell.m:

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if ( self )
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.textLabel.textColor = [UIColor yellowColor];
    }

    return self;
}

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

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
     [super setHighlighted:highlighted animated:animated];
     [self highlight:highlighted];

}

- (void)highlight:(BOOL) highlight {
     UIColor *tintColor = [UIColor whiteColor];
     if ( highlight ) 
          tintColor = [UIColor colorWithWhite:1.0 alpha:0.6];

     self.textLabel.textColor = tintColor;
}
WPOptionsTableViewController.m:

- (void)viewDidLoad {
     [super viewDidLoad];

     self.tableView.delegate = self;
     self.tableView.dataSource = self;
     self.tableView.backgroundColor = [UIColor redColor];
     self.tableView.contentInset = UIEdgeInsetsMake(80, 0.0, 0.0, 0.0);
     self.clearsSelectionOnViewWillAppear = NO;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

// Return the number of rows in the section.
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     OptionsTableViewCell *cell = [[OptionsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"OptionsTableViewCell"];
     if ( indexPath.row == 0 )
         cell.textLabel.text = @"Home";
     if ( indexPath.row == 1 )
        cell.textLabel.text = @"Profile";
     if ( indexPath.row == 2 )
        cell.textLabel.text = @"Settings";
     return cell;
}
无需使用dequeueReusableCellWithIdentifier,因为我只有3行


编辑:我不使用任何XIB文件。问题似乎出在我的自定义单元格实现中,但我看不出有任何错误。

这是因为,您在OptionTableViewCell的高亮显示方法中将textColor设置为白色。默认情况下,由于其未高亮显示,高亮显示的BOOL值将为“否”。请给出一个else条件,并将着色颜色替换为黑色。你可以看到文本

UIColor *tintColor = [UIColor blackColor];

是的,这就是问题所在。文本颜色始终为白色或“较软”的白色,而不是黄色。