简体   繁体   中英

how to use XIB with TableView - code ignores the XIB

I have a XIB with a Tableview. I assigned the datasource and the delegate to the Files Owner.

   List *screen = [[List alloc] initWithNibName:@"List" bundle:[NSBundle mainBundle]];
self.Search = screen;
[screen release];

[mainNavController pushViewController:screen animated:YES];

I push the screen using the above. However it ignores the XIB and it seems to load a generic tableview. If I omit the initWithNibName part, it works the same as with it.

I assume there must be something I needed to tie the XIB to the code, but not sure what.

You are releasing the screen before you push it. do this:

List *screen = [[List alloc] initWithNibName:@"List" bundle:[NSBundle mainBundle]];
self.Search = screen;

[mainNavController pushViewController:screen animated:YES];

[screen release];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM