• iOS @protocol UIContentContainer <NSObject>


    @protocol UIContentContainer <NSObject>

    @property (nonatomic, readonly) CGSize preferredContentSize ;//iOS8之后,加入了新的一组协议,UIViewController对这组协议提供了默认的实现,我们自定义ViewConttroller的时候可以重写这些方法来调整视图布局。

    - (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container ;//我们可以使用preferredContentSize来设置我们期望的childViewController的界面的大小

    - (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container;//我们可以使用preferredContentSize来设置我们期望的childViewController的界面的大小

    - (CGSize)sizeForChildContentContainer:(id <UIContentContainer>)container withParentContainerSize:(CGSize)parentSize);//.同上,依旧因为iOS8上size class概念的提出,UIViewConteroller支持了UIConntentContainer这样一组新的协议,重写这些方法可以调整视图布局,一个容器viewController可以使用这个方法设置childViewController的size,当容器viewControllerViewWillTransitionTosize:withTransitionCoordinator:被调用时(我们重写这个方法时要调用super),sizeForChildContentContainer方法将被调用。然后我们可以把需要设置desire发送给childViewController。当我们设置的这个size和当前childViewController的size一样,那么childViewController的viewWillTransitionToSize方法将不会被调用。sizeForChildContentContainer默认的实现是返回parentSize

    /* 

     This method is called when the view controller's view's size is changed by its parent (i.e. for the root view controller when its window rotates or is resized). 

     If you override this method, you should either call super to propagate the change to children or manually forward the change to children.

     */

    - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator NS_AVAILABLE_IOS(8_0);

    /* 

     This method is called when the view controller's trait collection is changed by its parent.

     If you override this method, you should either call super to propagate the change to children or manually forward the change to children.

     */

    - (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator NS_AVAILABLE_IOS(8_0);

    @end

  • 相关阅读:
    Android4.0 以后不允许在主线程进行网络连接
    关于升级linux下apache
    事物复制中大项目(Large Article)出问题如何快速修复
    国企银行面试总结
    Git命令详解(一)-个人使用
    函数体的规模要小,尽量控制在 50 行代码之内
    函数的功能要单一,不要设计多用途的函数
    在函数体的“出口处”,对 return 语句的正确性和效率进行检查
    在函数体的“入口处”,对参数的有效性进行检查
    有些场合用“引用传递”替换“值传 递”可以提高效率
  • 原文地址:https://www.cnblogs.com/lsh1234/p/6553447.html
Copyright © 2020-2023  润新知