0

アプリを iOS 7 に更新しようとしていますが、多くのものが消えたか、機能しなくなりました :S.

私はこの問題を理解できません.なぜNULLを返すのかわかりません.

*** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6061
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'


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

static NSString *cellIdentifier = @"Cell";

static NSString *cellIdentifier2 = @"Cell2";


NSDictionary *naamInfo;

if (tableView == self.searchDisplayController.searchResultsTableView) {
    naamInfo = [self.filteredNameArray objectAtIndex:indexPath.row];
} else {
    naamInfo = [self.nameList objectAtIndex:indexPath.row];
}



UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if ([[naamInfo objectForKey:@"gender" ] isEqual: @"man"] ) {

        cell = [UITableViewCell configureFlatCellWithColor:[UIColor peterRiverColor] selectedColor:[UIColor cloudsColor] reuseIdentifier:cellIdentifier inTableView:tableView];

    }else if ([[naamInfo objectForKey:@"gender" ] isEqual: @"woman"]){
        cell = [UITableViewCell configureFlatCellWithColor:[UIColor colorWithRed:1 green:0.396 blue:0.604 alpha:1]  selectedColor:[UIColor cloudsColor] reuseIdentifier:cellIdentifier2 inTableView:tableView];

    }

NSLog(@"CELL %@",cell);

    cell.detailTextLabel.font = [UIFont boldFlatFontOfSize:14];

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.cornerRadius = 8.f; 
    cell.separatorHeight = 1.f; 

cell.textLabel.font = [UIFont boldFlatFontOfSize:18];
cell.textLabel.text = [naamInfo objectForKey:@"name"];
cell.detailTextLabel.text = [naamInfo objectForKey:@"country"];

return cell;

}

ログは NULL を返すので、例外が発生する理由は理解できますが、この問題を解決するにはどうすればよいでしょうか?

4

1 に答える 1

2

入れてみてください:

if (cell == nil) {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

}

後:

UITableViewCell *cell = [tableView dequeue....
于 2013-10-02T19:31:18.710 に答える