[self transitionFromViewController:oldController toViewController:newController duration:0.0 options:0 animations:nil completion:nil];

/*

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当前显示在父视图控制器中的子视图控制器

*  toViewController将要显示的姿势图控制器

*  duration动画时间(这个属性,old

friend了O(∩_∩)O)

*  options动画效果(渐变,从下往上等等,具体查看API)

*  animations转换过程中得动画

*  completion转换完成

*/

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);

}];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ViewsBecause view objects are the main way your applicati...
    梁光飞阅读 3,887评论 0 0
  • 观察者模式是指一个或者多个对另外一个对象进行观察,当观察对象发生变化时,观察者可以直接或者间接地得到通知,从而能自...
    司夜阅读 1,486评论 1 0
  • 互联网时代,每个人都知道要快,快速出方案、快速设计、快速开发、快速上线、快速迭代。跑得快的吃肉喝汤,跑得慢连骨头都...
    无邪阅读 5,309评论 0 3
  • 有个男孩爱上一位女神 那个男孩每天买早餐送到女神面前与女神共进早餐! 晚上陪女神逛街,看电影,送女神回家。充当女神...
    叶子随风流逝阅读 3,868评论 4 3
  • 对于一个人来说,你的个人商业模式路线图可以简单概括如下: 给别人打工,找个买家出售自己的时间——给老板打工的同时给...
    酒慰风雨夕阅读 1,711评论 0 0

友情链接更多精彩内容