• iOS iOS8新特性--UIPresentationController


    1. UIPresentationController的作用

      1>管理所有Modal出来的控制器

      2>管理通过这个方法  - (void) presentViewController:(UIViewController *) animated:(BOOL) completion:^(void)completion;显示出来的控制器

      3>管理监听 切换控制器的过程

    2. UIPresentationController的作用

      1>控制器一旦调了present方法,控制器的presentationController,会先创建好了,然后整个控制器的切换由presentationController管理

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

        SecondViewController *vc = [[SecondViewController alloc]init]; 

        [self presentViewController:vc animated:YES completion:nil];

    }

     

      2>控制器有2个属性:presentationController和poppverPresentationController

        下面的截图场景 vc.modalPresentationStyle = UIModalPresentationFormSheet, 这种情况下poppverPresentationController = nil 

      

      3>设置控制器以popver的方式切换.

        也就是说 vc.modalPresentationStyle = UIModalPresentationPopover,控制器的popoverPresentationController属性就不再是nil了

        而且popoverPresentationController 和 presentationController 指向同一对象,指向的都是 UIPopoverPresentationController 类对象

        注: 1>UIPopoverPresentationController类 继承自 UIPresentationController类

            2>父类指针可以指向子类,所以presentationController指向UIPopoverPresentationController对象,没有问题

      4>控制器的presentationController 和 popoverPresentationController采用的是懒加载的方式,下面这段代码,vc控制器是不会popover出来的.

        SecondViewController *vc = [[SecondViewController alloc]init];

        // 在 vc.popoverPresentationController.sourceView = self.segmented之前调了presentationController的get方法

      vc.presentationController; 

        vc.modalPresentationStyle = UIModalPresentationPopover;

        vc.popoverPresentationController.sourceView = self.segmented;

        [self presentViewController:vc animated:YES completion:nil];

  • 相关阅读:
    canvas 学习
    configure/autoconf/automake文件相关
    git add A 和 git add . 的区别详解
    Vim格Vim格式化代码功能——gg=G式化代码功能——gg=G
    详解git commit amend 用法
    git reset HEAD 与 git reset hard HEAD的区别 天地逍遥
    git的撤销操作:reset、checkout和revert
    参与linux社区
    git制作补丁
    git diff、git diff head、git diff cached三者详细区分
  • 原文地址:https://www.cnblogs.com/oumygade/p/4279532.html
Copyright © 2020-2023  润新知