0
votes

I want to create custom UiTableViewCell, and it works, when I create TableView, like in this example, by inherit from UIViewController. But when I create controller which inherit from UITableViewController (not UIViewController), and in xib create UITableViewCell, and of course hook up IBOutlet, i get this error:

*** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:5678

2011-05-06 07:21:34.107 tabela[11424:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { return cellOne; }
1
This was asked literally an hour ago: stackoverflow.com/questions/5906592/… . Short story is, make your custom UITableViewCell programmatically (rather than in IB). - Alan Zeino
show your code for cellForRow - visakh7

1 Answers

0
votes

This is the sample reference

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// In your case it has to be the custom cell object here.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AnIdentifierString"];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"AnIdentifierString"] autorelease];
    }

    cell.textLabel.text = @"This text will appear in the cell";


    return cell;
}