Iphone UINavigationController SetViewController似乎不适合我

Iphone UINavigationController SetViewController似乎不适合我,iphone,ios,uinavigationcontroller,Iphone,Ios,Uinavigationcontroller,我确信这是我的问题,而不是navigationController类的问题。我正在使用NavigationController跟踪最多为2的ViewController堆栈。因此,当有1个或更少的风险投资时,我会推出一个新的风险投资。当有两个I时,用一个包含新VC的堆栈替换堆栈,并剥离出我刚才所在的位置。代码如下所示: - (IBAction)displayNextView:(id)sender { FBRightVC *nextVC = [[FBRightVC alloc] init

我确信这是我的问题,而不是navigationController类的问题。我正在使用NavigationController跟踪最多为2的ViewController堆栈。因此,当有1个或更少的风险投资时,我会推出一个新的风险投资。当有两个I时,用一个包含新VC的堆栈替换堆栈,并剥离出我刚才所在的位置。代码如下所示:

- (IBAction)displayNextView:(id)sender 
{
    FBRightVC *nextVC = [[FBRightVC alloc] init];

    if ([[self.navigationController viewControllers] count] <= 1)
    {
        [self.navigationController pushViewController: nextVC 
                                             animated: YES];
        NSLog(@"iffy");
    } 
    else if ([[self.navigationController viewControllers] count] == 2)
    {
        NSMutableArray *newVCArray = [[NSMutableArray alloc] initWithObjects: 
                                      [[self.navigationController viewControllers] objectAtIndex:0],  nextVC, nil];
        NSLog(@"VC's in newVCArray = %i", [newVCArray count]);
        [self.navigationController setViewControllers: newVCArray animated: NO];
        NSLog(@"VC's in navigationController VC Array = %i", [self.navigationController.viewControllers count]);
        [newVCArray release];
    }
    [nextVC release];
}
-(iAction)显示下一个视图:(id)发送方
{
FBRightVC*nextVC=[[FBRightVC alloc]init];

如果([[self.navigationController viewControllers]count]不应该是
[self.navigationController setViewControllers:newVCArray动画:否]
?是的,应该是。我会更正代码。即使进行了更正,结果仍然是一样的。是的,您应该释放NSMutableArray,SetViewController:animated:会将其保留一段时间you@XSlash谢谢你回答问题的内存管理部分。我已经修改了我的代码。尽管有你的建议,UINavigationController的行为是相同的。@KrishnaK
[self.navigationController SetViewController:ViewController动画:否]
[self.navigationController SetViewController:ViewController]
是相同的(参见)“将视图控制器的新数组分配给此属性相当于调用SetViewController:animated:方法,并将动画参数设置为否。”它不应该是
[self.navigationController SetViewController:newVCArray animated:否]
?是的,应该是。我会更正代码。即使进行了更正,结果仍然是一样的。是的,您应该释放NSMutableArray,SetViewController:animated:会将其保留一段时间you@XSlash谢谢你回答问题的内存管理部分。我已经修改了我的代码。尽管有你的建议,UINavigationController的行为是相同的。@KrishnaK
[self.navigationController设置视图控制器:视图控制器已设置动画:否]
[self.navigationController设置视图控制器:视图控制器]
是相同的(cf.)“将视图控制器的新数组指定给此属性相当于调用SetViewController:animated:方法,并将动画参数设置为“否”