2010-06-21 101 views
1

我用下面的代码到一个按钮添加到我的导航栏,按下会调用该方法showCountries时:加载按钮按下后表视图笔尖

UIBarButtonItem *countriesButton = [[UIBarButtonItem alloc] initWithTitle:@"Countries" style: UIButtonTypeRoundedRect target:self action:@selector(showCountries:)]; 
self.navigationItem.leftBarButtonItem = countriesButton; 
[countriesButton release]; 

现在这个作品中,按钮出现,当按下按计划前往showCountries方法。

show countries方法需要做的是加载一个新的表视图,其中包含一个错误国家列表(目前在一个数组中)。

为此,我曾尝试下面的代码:

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

[self.navigationController pushViewController:controller animated:YES]; 

一切似乎编译罚款,但使用时出现在控制台下面的错误和繁荣的应用程序崩溃:

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

我一直在抓我的头2天,现在这么pleeeeease如果你能发现我的错误,请告诉我。

我也尝试加载一个普通的笔尖文件,这工作得很好。

回答

0

是的 - 我发现了这个问题。这是因为我在第一个视图中声明了第二个视图控制器,然后释放它。我已经把它移到了我的应用程序代表,它已经解决了这个问题。

我已经创建了一个测试项目,演示了这个应该有谁发现这个有用。 link text