1.可以使用导航控制器栈。将当前视图控制器作为rootViewController.需要在创建当前控制器的代码中这样来创建 UIViewController *vc1=[[UIViewControlelr alloc] init]; UINavigationController *navController =[[UINavigationController alloc] initWithRootViewController:vc1]; [vc1 release]; [window addSubView:navController.view]; [navController release]; 只有当当前控制器在导航控制器栈中才可以使用pushViewController来导航其它视图 导航到新的视图控制器: UIViewController *vc2=[[ViewController alloc] init]; [self.navigationController pushViewController:vc2 animated:YES]; [vc2 release]; 2.模态视图 UIViewController *vc2=[[ViewController alloc] init]; [self presentModalViewController:controller animated:YES]; [vc2 release]; 3.使用新的视图覆盖当前视图 如果使用这种方式,建议创建一个可维护控制器之间交互的控制器swithController,在这个控制器中来实现不同控制器之间的视图切换 @inertface SwitchViewController:UIViewController @property(retain) UIViewController *vc1 @property (retain) UIViewController *vc2; -(void)showVC1; -(void)showVC2; @end @implementation SwitchViewController @synthesize vc1,vc2; -(void)showVC1 { if (vc2) { [vc2.view removeFromSuperView]; } [self.view addSubView:vc1.view]; } @end 其他:
一种就是对View的操作,把直接的View移除掉,一种就是让本身的ViewController的根视图为UINavigationController依托,然后push进去,返回时在pop出来
ios和android不一样,只需要在将你需要的Controller加载进来可以了。