Iphone 将视图推送到第二个导航控制器

Iphone 将视图推送到第二个导航控制器,iphone,Iphone,我有一个tabbar应用程序,它有两个项。这两个不同的选项卡项包含两个不同的导航控制器。 第一个导航控制器工作正常,但当我想将视图推送到第二个导航时,它会生成 “应用程序试图将nil视图控制器推送到目标上” 下面是我将视图推送到第二个导航控制器的代码 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { TabNavAppDelegate *appDelegat

我有一个tabbar应用程序,它有两个项。这两个不同的选项卡项包含两个不同的导航控制器。 第一个导航控制器工作正常,但当我想将视图推送到第二个导航时,它会生成 “应用程序试图将nil视图控制器推送到目标上”

下面是我将视图推送到第二个导航控制器的代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

TabNavAppDelegate *appDelegate = (TabNavAppDelegate *)[[UIApplication sharedApplication] delegate];
JJ_MapAnnotation *anno = (JJ_MapAnnotation *) [depotsArray objectAtIndex:indexPath.row];
if(self.secondViewController ==nil)
{
    SecondViewController *secView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    self.secondViewController == secView;
    [self.secondViewController.map addAnnotation:anno];
    [secView release];
}


secondViewController.title = [NSString stringWithFormat:@"%@", [anno title]];

[appDelegate.navController pushViewController:secondViewController animated:YES]; 

我敢打赌:

if(self.secondViewController ==nil)
self.secondViewController
不是
nil
也不是有效的对象。可能里面有垃圾。 当您执行这种动态分配时,请确保对象在释放后变为零。否则你可以有这样的案子。 我希望有帮助

更新:

=
这里的运算符不正确;)


您好,谢谢您的快速回复,但即使我删除了该代码,它仍然会生成相同的错误
self.secondViewController == secView; //WRONG
self.secondViewController = secView; //OK