IOS视图切换

iPhone开发中从一个视图跳到另一个视图有三种方法:

引用
1、self.view addSubView:view 、self.window addSubView,需要注意的是,这个方法只是把页面加在当前页面。此时在用self.navigationControler.pushViewController和 pushViewController 是不行的。要想使用pushViewController和popViewController进行视图间的切换,就必须要求当前视图是个NavigationController。

2、就是使用self.navigationControler pushViewController和popViewController来进行视图切换的,pushViewController是进入到下一个视图,popViewController是返回到上一视图。

3、没有NavigationController导航栏的话,使用self.presentViewController和self.dismissModalViewController。

4、要想使用pushViewController和pushViewController来进行视图切换,首先要确保根视图是NavigationController,不然是不可以用的。这里提供一个简单的方法让该视图或者根视图是NavigationController。自己定义个子类继承UINavigationController,然后将要展现的视图包装到这个子类中,这样就可以使这个视图是个NavigationController了。提供的这个方法有很好的好处,就是可以统一的控制各个视图的屏幕旋转。

以上转自
http://blog.csdn.net/yuanya/article/details/10491479

遇到了一个问题记录一下
我起初用的是presentViewController,但是切换到第二个view之后,整个nav的导航风格不一样,不能继承上一个,换成pushViewController之后就可以了

猜你喜欢

转载自chinacheng.iteye.com/blog/2157395