【发布时间】:2010-06-21 17:11:22
【问题描述】:
我使用以下代码向导航栏添加了一个按钮,按下该按钮将调用方法 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 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]
我已经挠头 2 天了,如果你能发现我的错误,请告诉我。
我也尝试加载一个普通的 nib 文件,效果很好。
【问题讨论】:
标签: xcode uitableview nib