Xcode 按下按钮后加载表视图nib

Xcode 按下按钮后加载表视图nib,xcode,uitableview,nib,Xcode,Uitableview,Nib,我使用以下代码在导航栏中添加了一个按钮,按下该按钮将调用showCountries方法: UIBarButtonItem *countriesButton = [[UIBarButtonItem alloc] initWithTitle:@"Countries" style: UIButtonTypeRoundedRect target:self action:@selector(showCountries:)]; self.navigationItem.leftBarButtonIte

我使用以下代码在导航栏中添加了一个按钮,按下该按钮将调用showCountries方法:

    UIBarButtonItem *countriesButton = [[UIBarButtonItem alloc] initWithTitle:@"Countries" style: UIButtonTypeRoundedRect target:self action:@selector(showCountries:)];
self.navigationItem.leftBarButtonItem = countriesButton;
[countriesButton release];  
现在,该功能开始工作,按钮出现,按下后按计划转到showCountries方法

show countries方法需要做的是加载一个新的表视图,其中包含当前位于数组中的err国家的列表

为此,我尝试了以下代码:

    UIViewController *controller = [[UIViewController alloc] initWithNibName:@"countriesViewController" bundle:nil];

[self.navigationController pushViewController:controller animated:YES];
所有这些似乎都可以编译,但使用时,控制台中会出现以下错误,应用程序会崩溃:

2010-06-21 18:09:02.076 Vat Pro[788:207]*-[UIViewController tableView:numberOfRowsInSection:]:发送到实例0x12a920的选择器无法识别 2010-06-21 18:09:02.082 Vat Pro[788:207]*由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'***-[UIViewController tableView:numberOfRowsInSection:::]:未识别的选择器发送到实例0x12a920' 2010-06-21 18:09:02.088增值税专业[788:207]

我已经挠头两天了,如果你能发现我的错误,请告诉我


我还尝试加载一个普通的nib文件,效果很好。

是的-我发现了问题。这是因为我从第一个视图中声明了第二个视图控制器,然后将其释放。此后,我将其移动到我的应用程序代理,解决了该问题

我已经创建了一个测试项目来演示这一点,如果其他人觉得这很有用的话。