iOS @protocol UIContentContainer

@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

相關文章
相關標籤/搜索