Ios TableView在重新加载数据时崩溃-';无法识别的选择器发送到实例';

Ios TableView在重新加载数据时崩溃-';无法识别的选择器发送到实例';,ios,objective-c,iphone,uitableview,Ios,Objective C,Iphone,Uitableview,在我的tableView的cellforrowatinexpath方法中,我对第一行使用自定义单元格,对其他行使用常规的UITableViewCell: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"Cell"; if (indexPath.sec

在我的
tableView
cellforrowatinexpath
方法中,我对第一行使用自定义单元格,对其他行使用常规的
UITableViewCell

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *MyIdentifier = @"Cell";

    if (indexPath.section == 0){
        CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];

        if (cell == nil)
        {
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCell" owner:self options:nil];
            cell = [nib objectAtIndex:0];
        }

        cell.titleLabel.text = @"Custom cell";

        if (isLightTheme){
           cell.titleLabel.textColor = [UIColor blackColor];
        }
        else{
           cell.titleLabel.textColor = [UIColor whiteColor];
        }

        return cell;
    }
    else{
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:MyIdentifier];
        }

        cell.textLabel.text = @"Other cells";

        if (isLightTheme){
            cell.textLabel.textColor = [UIColor blackColor];
        }
        else{
            cell.textLabel.textColor = [UIColor whiteColor];
        }

        return cell;

    }
}

然后我调用一个方法来更改isLightTheme并重新加载数据:

-(void)changeTheme{

   isLightTheme = false;
   [self.myTable reloadData];
}
。。。但我的应用程序在这一行崩溃了:

    cell.titleLabel.text = @"Custom cell";
错误如下:

'-[UITableViewCell标题标签]:发送到实例的选择器无法识别


我不明白发生了什么事。。当
ViewController
第一次加载时,表的加载非常好(
isLightTheme
首先设置为
true
),但当我更改
isLightTheme
重新加载数据时,表崩溃。有人能帮我吗?谢谢。

两个单元格的重用标识符相同。自定义和默认设置。对每种类型使用唯一的值

很乐意帮忙!UITableViews可能会让人沮丧,但你很快就会爱上它们的。;-)