changjiashuai's blog

Runnig...

The future belongs to those who believe in the beauty of their dreams.


iOS页面切换的几种方式

从一个视图控制器切换到另一个视图控制器的几种方式

  1. 模态(modal)画面显示方式

     //显示模态画面
     [self presentModalViewController: ... animated: ... ];
     //关闭模态画面
     [self dissmissModalViewController: ... animated: ... ];
    
  2. SwitchViewController中有2个控制器的属性:BViewController,CViewController

    点击按钮之后在B与C视图之间切换–多用于在一个页面中有时要显示或隐藏某个View

     [self.view insertSubview: 加载的新页面 atIndex: n ];
    

3.UITabBarController实现并列画面跳转

    //将5个ViewController实例放入TabBar的viewControllers属性中
    self.tabBarController.viewControllers = @[navFirst, navSecond, navThird, navFourth, navFifth];
    self.window.rootViewController = self.tabBarController;
    //将根控制器的视图加到应用程序的主窗口
    [self.window addSubview: self.tabBarController.view];

4.UINavigationController实现多层画面跳转,在导航控制器中,载入有层级关系的界面

    [self.navigationController pushViewController: ... animated: ... ];
    //弹出后返回到原视图
    [self.navigationController popViewController: ... animated: ... ];
最近的文章

iOS坐标系统frame和bounds的区别(位置和大小)

iOS 首先左上角为坐标原点(0,0) CGPoint创建坐标点也就是位置 CGSize表示视图宽度和高度 CGRect结合了CGPoint和CGSize origin表示左上角所在的CGPoint frame是在父视图的CGRect bounds是指在自身视图中的CGRect center是指在父视图中的CGPoint cocos2d 首先左下角为坐标原点(0,0) anchorPoint中心点(0.5,0.5) ...…

继续阅读