@protocol UIContentContainer <NSObject>ide
@property (nonatomic, readonly) CGSize preferredContentSize ;//iOS8以后,加入了新的一组协议,UIViewController对这组协议提供了默认的实现,咱们自定义ViewConttroller的时候能够重写这些方法来调整视图布局。布局
- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container ;//咱们能够使用preferredContentSize来设置咱们指望的childViewController的界面的大小this
- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container;//咱们能够使用preferredContentSize来设置咱们指望的childViewController的界面的大小atom
- (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默认的实现是返回parentSizeit
/* io
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). class
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);call
/*
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