/*
This method can be used to transition between sibling child view controllers.
The receiver of this method is their common parent view controller. (Use [UIViewController
addChildViewController:] to create the parent/child relationship.) This method will add the toViewController's view to the superview of the fromViewController's view and the fromViewController's view will be removed from its superview after the transition completes. It is important to allow this method to add and remove the views. The arguments to this method are the same as those defined by UIView's block animation API. This method will fail with an NSInvalidArgumentException if the parent view controllers are not the same as the receiver, or if the receiver explicitly forwards its appearance and rotation callbacks to its children. Finally, the receiver should not be a subclass of an iOS container view controller. Note also that it
is possible to use the UIView APIs directly. If they are used it is important to ensure that the
toViewController's view is added to the visible view hierarchy while the fromViewController's view is removed.
*/
- (void)transitionFromViewController:(UIViewController*)fromViewController toViewController:(UIViewController*)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void(^__nullable)(void))animations
completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(5_0);
/**
*切換控制器
*
*? @param oldController舊控制器
*? @param newController新控制器
*/
- (void)replaceController:(QDFViewController*)oldController newController:(QDFViewController*)newController
{
/**
*著重介紹一下它
*
transitionFromViewController:toViewController:duration:options:animations:completion:
*? fromViewController當(dāng)前顯示在父視圖控制器中的子視圖控制器
*? toViewController將要顯示的姿勢圖控制器
*? duration動畫時間(這個屬性,old
friend了O(∩_∩)O)
*? options動畫效果(漸變,從下往上等等,具體查看API)
*? animations轉(zhuǎn)換過程中得動畫
*? completion轉(zhuǎn)換完成
*/
if(newController == oldController) {
return;
}
oldController.visible=NO;
newController.visible=YES;
[self addChildViewController:newController];
if(!oldController) {
[self.rightPlaceholderView addSubview:newController.view];
self.currentVC = newController;
}
else{
[self ?transitionFromViewController:oldController toViewController:newController duration:0.0 options:0 animations:nil completion:nil];
[newController didMoveToParentViewController:self];
[oldController willMoveToParentViewController:nil];
[oldController removeFromParentViewController];
self.currentVC = newController;
}
[newController.view mas_makeConstraints:^(MASConstraintMaker*make) {
make.edges.equalTo(self.rightPlaceholderView);
}];
}