在不推送视图的情况下调用视图控制器

时间:2012-02-06 11:45:28

标签: objective-c ios4

有3个视图view1,view2,view3

From view1 there is a function which calls view2
{
view2* view2Controller =[[view2 alloc]initWithNibName:@"view2" bundle:nil];       
        [ view2Controller SessionMaintained];
      //  [self.navigationController pushViewController:view2Controller animated:YES]; 
}

now in view 2 call is made to view3
{
view3* view3Controller =[[view3 alloc]initWithNibName:@"view3" bundle:nil];       
        [ view3Controller SessionMaintained];
        [self.navigationController pushViewController:view3Controller animated:YES]; 
}

现在我想直接推送view3而不推送view2

2 个答案:

答案 0 :(得分:0)

直接创建View3对象并推入View1是什么问题?

答案 1 :(得分:0)

所以我自己回答你的问题

从view1有一个调用view2的函数

{
view2* view2Controller =[[view2 alloc]initWithNibName:@"view2" bundle:nil];       
        [ view2Controller SessionMaintained];
//push view2 w/o animation
        [self.navigationController pushViewController:view2Controller animated:NO]; 
//call some method (say showView3) in view2
        [view2Controller showView3];
        [view2Controller release];
}

现在在视图2(showView3方法)中,调用view3

{
view3* view3Controller =[[view3 alloc]initWithNibName:@"view3" bundle:nil];       
        [ view3Controller SessionMaintained];
        [self.navigationController pushViewController:view3Controller animated:YES]; 
}