我正在尝试编辑添加按钮以推送到另一个视图。 但我收到错误
-(void)locationAdd:(id)sender{
if([self.parentViewController isKindOfClass:[UINavigationController class]]){
UINavigationController *parent = (UINavigationController *)self.parentViewController;
if ([[parent viewControllers] objectAtIndex:0] == self) {
LocationsAddViewController *alocationAddViewController = [[[LocationsAddViewController alloc] initWithNibName:@"LocationAddView" bundle:[NSBundle mainBundle]] autorelease];
//self.locationAddViewController = alocationAddViewController;
alocationAddViewController.title = @"Toevoegen";
[self.parentViewController pushViewController:alocationAddViewController animated:YES];
}
else if([[parent viewControllers] objectAtIndex:2] == self){
LocationsAddViewController *alocationAddViewController = [[[LocationsAddViewController alloc] initWithNibName:@"LocationAddView" bundle:[NSBundle mainBundle]] autorelease];
alocationAddViewController.title = @"Toevoegen";
[self.parentViewController pushViewController:alocationAddViewController animated:YES];
}
}
}
因为可以从其他2个视图到达视图并且它必须看起来不同,所以我使用了
if([self.parentViewController isKindOfClass:[UINavigationController class]]){
UINavigationController *parent = (UINavigationController *)self.parentViewController;
if ([[parent viewControllers] objectAtIndex:0] == self) {
检查它的来源。
问题在于: [self.parentViewController pushViewController:alocationAddViewController animated:YES]; 我收到错误:
+ [LocationsTableViewController pushViewController:animated:]:无法识别的选择器发送到类0x23510 ***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'+ [LocationsTableViewController pushViewController:animated:]:无法识别的选择器发送到类0x23510'
有人能帮助我吗? 我做错了什么?
答案 0 :(得分:0)
您的错误表明您尝试在pushViewController:animated:
类对象上调用LocationsTableViewController
。鉴于您发布的代码,这不可能实现。你确定你粘贴了引发异常的确切代码吗? (我怀疑你的if
和else if
块完全相同。)