2012-05-05 58 views
0

试图将新控制器推入navigationController,不知道为什么它不是woking。 1)我检查了secondViewController的实例也不起作用。 2)。试图”后面添加的.xib”,也没有工作 3)尝试捆绑:。零也没有工作无法将子视图推送到navigationController

我使用ARC有人能指出什么是这里的问题

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSLog(@" YOU SELECTED ROW .."); 
    secondViewController *secController = [[secondViewController alloc] initWithNibName:@"secondViewController.xib" bundle:[NSBundle mainBundle]]; 
    NSLog (@"View Controller %@ ", secController); 
     [self.navigationController pushViewController:secController animated:YES]; 
    } 
+0

你为什么使用ARC而不是故事板?这可能会解决你的问题。我们是否还可以获得更多的代码,比如你的UINavigationController实例,以及你的意思是它不工作?它是否崩溃,空白,只是没有做任何事情? NSControl for secController显示什么? –

+0

你在你的MainWindow.xib文件中实现了UINavigationController吗? – akk

回答

0

我编辑你的代码只是试试这个。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSLog(@" YOU SELECTED ROW .."); 
    secondViewController *secController = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil]; 
    NSLog (@"View Controller %@ ", secController); 
    [self.navigationController pushViewController:secController animated:YES]; 
} 
+0

并检查您的文件所有者的第二个视图控制器xib.Inxib任何警告连接不应该在那里。 – vishiphone

0

你不? “T需要通过捆绑的,如果笔尖位于主束在零将工作路过,所以更改此:

[[secondViewController alloc] initWithNibName:@"secondViewController.xib" bundle:[NSBundle mainBundle]]; 

要这样:

[[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil]; 

您还可以利用UIKit将寻找与班级名称相同的笔尖并通过nil获取笔尖名称的事实。

0

点击here

此链接为如何创建导航控制器,你想要什么。我已经在这个链接中编写了代码。我希望这会对你有所帮助。

0

您是否使导航控制器安全?检查self.NaviagationController是否在内存中?可能是0 * 0

相关问题