简体   繁体   English

如何在 TableView 中使用 XIB - 代码忽略 XIB

[英]how to use XIB with TableView - code ignores the XIB

I have a XIB with a Tableview.我有一个带有 Tableview 的 XIB。 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.然而,它忽略了 XIB,它似乎加载了一个通用的 tableview。 If I omit the initWithNibName part, it works the same as with it.如果我省略 initWithNibName 部分,它的工作原理与它相同。

I assume there must be something I needed to tie the XIB to the code, but not sure what.我认为必须有一些东西可以将 XIB 与代码联系起来,但不确定是什么。

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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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