Problem loading UITableView in navigation based application

In a navigation based application, when I try to load another view that is implemented UITableViewusing initWithNibName:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *detailsViewController = [[UIViewController alloc] initWithNibName:@"bloop2ViewController" bundle:nil];
    [[self navigationController] pushViewController:detailsViewController animated:YES];
    [detailsViewController release];
}

after clicking the UITableViewcell I get:

2009-06-13 11:44:41.089 Bloop[75227:20b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0xd446f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.' 2009-06-13 11:44:41.092 Bloop[75227:20b] Stack: (
807902715, 2429103675, 808061681, 810717848, 810716389, 816538544, 807805711, 816533170, 816541363, 815230552, 815224116, 815223834, 815217291, 815258907, 815254969, 815262662, 815243017, 815265053, 815242666, 11044, 815018240, 815005661, 810768858, 807687328, 807683624, 839142449, 839142646, 814752238, 9088, 8942 )

But when I disconnect UITableViewin InterfaceBuilder, the view loads without any problems (except that there is no way to insert data into it).

The UITableView implementation is correct - I tried it in a new Xcode project and it worked great.

+3
source share
5 answers

, "tableView" UIViewController, . , , , nib, tableView, , UIViewController. :

MyTableViewController *detailsViewController = [[MyTableViewController alloc] initWithNibName:@"bloop2ViewController" bundle:nil];
+6

, , ,

  • NIB xib
  • sub-view.

.

0

. MyTableViewController, . , -.

0

, . xib . , , . , , , . - xib .

0

2

@synthesize tableView = _tableView;

,

0

Source: https://habr.com/ru/post/1710397/


All Articles