0

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; }
juantorena
  • 71
  • 1
  • 9
  • This was asked literally an hour ago: http://stackoverflow.com/questions/5906592/initialize-custom-uitableviewcell/5906614#5906614 . Short story is, make your custom UITableViewCell programmatically (rather than in IB). – Alan Zeino May 06 '11 at 05:36
  • show your code for cellForRow – visakh7 May 06 '11 at 05:40

1 Answers1

0

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;
}
visakh7
  • 26,380
  • 8
  • 55
  • 69
  • yeah I know, but I only want to check if this is working so I wrote: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { return cellOne; } cellOne is of course hooked up – juantorena May 06 '11 at 05:51
  • pls see if this helps http://iphone.zcentric.com/2008/08/05/custom-uitableviewcell/ – visakh7 May 06 '11 at 05:58
  • Yes, I know that this is working, there is hundreds ways to create custom uitableviewCell, but I want to know WHY MY implementation doesn't work. – juantorena May 06 '11 at 06:08