我正在制作一个具有2个导航控制器的应用程序。其中有一个的tableView,当细胞中的水龙头,我要加载其他的viewController,但我一直有这样的错误:多导航控制器错误
fifthvieController may no respond to -navigationController2
下面的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *letraSeleccionada = [lista objectAtIndex:indexPath.row];
FourthViewController *fourth = [[FourthViewController alloc]initWithNibName:@"FourthViewController" bundle:nil];
fourth.letraSeleccionada = letraSeleccionada;
[[self navigationController2] pushViewController:fourth animated:YES]; //here
[fourth release];
fourth = nil;
}
我已经改变了编码现在它的工作原理,但我不明白为什么之前它不工作。这里的新代码:
PruebaPushAppDelegate *delegate = [[UIApplication sharedApplication]delegate];
[delegate.navigationController2 pushViewController:fourth animated:YES];
//[[self navigationController2] pushViewController:fourth animated:YES];
我做到了,我AppDelegate.m。你有什么想法吗? – Evan 2011-05-28 01:46:01
由于navigationController2不是真正的选择器,而是属性,请尝试使用“。”。记法(self.navigationController2)。如果你的综合函数超出了这个函数被调用的地方,那么你将不会收到任何错误,否则你会得到一个错误而不是一个警告。我猜你上面粘贴的函数也在AppDelegate.m – Gary 2011-05-28 02:13:38
是的,我认为你没有将navigationController2声明为任何“self”类的属性。 (它可能与拼写错误一样简单,或者您可以在不同的类中声明该类,并且当前类不会从宣称的类继承。) – 2011-05-28 02:49:40