Iphone 无法将子视图推送到navigationController

Iphone 无法将子视图推送到navigationController,iphone,objective-c,ios5,Iphone,Objective C,Ios5,正在尝试将新控制器推入navigationController,但不确定为什么它不能正常工作。 1我检查了secondViewController的实例也不工作。 2.尝试了“.xib”后缀,但也不起作用。 3:零也不工作 我正在使用ARC。有人能指出这里的问题是什么吗 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@" YOU SELE

正在尝试将新控制器推入navigationController,但不确定为什么它不能正常工作。 1我检查了secondViewController的实例也不工作。 2.尝试了“.xib”后缀,但也不起作用。 3:零也不工作

我正在使用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];
    }

如果nib位于主捆绑包中,则不需要传入捆绑包。输入nil将有效,因此更改此选项:

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

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

您还可以利用这样一个事实,UIKit将查找与类同名的nib,并将nil传递给nib名称。

我编辑您的代码,请尝试一下

 -(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];
}

你安装了导航控制器吗?检查self.NaviagationController是否在内存中?可能是0*0

为什么使用ARC而不是故事板?那可能会解决你的问题。我们还可以得到更多的代码,比如您的UINavigationController实例化,以及您所说的不工作是什么意思?它是不是崩溃了,一片空白,什么都没做?secController的NSLog显示了什么?您是否在MainWindow.xib文件中实现了UINavigationController?并检查了第二视图控制器xib的文件所有者。在xib中,不应存在任何警告连接。