@@ -378,6 +378,8 @@ -(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:
378378}
379379
380380#pragma mark - Updating the Center View Controller
381+ // If animated is NO, then we need to handle all the appearance calls within this method. Otherwise,
382+ // let the method calling this one handle proper appearance methods since they will have more context
381383-(void )setCenterViewController : (UIViewController *)centerViewController animated : (BOOL )animated {
382384 if (_centerContainerView == nil ){
383385 _centerContainerView = [[MMDrawerCenterContainerView alloc ] initWithFrame: self .childControllerContainerView.bounds];
@@ -417,9 +419,14 @@ -(void)setCenterViewController:(UIViewController *)centerViewController animated
417419}
418420
419421-(void )setCenterViewController : (UIViewController *)newCenterViewController withCloseAnimation : (BOOL )animated completion : (void (^)(BOOL finished))completion {
422+
423+ if (self.openSide == MMDrawerSideNone){
424+ // If a side drawer isn't open, there is nothing to animate...
425+ animated = NO ;
426+ }
420427 [self setCenterViewController: newCenterViewController animated: animated];
421428
422- if (self. openSide != MMDrawerSideNone ){
429+ if (animated ){
423430 [self updateDrawerVisualStateForDrawerSide: self .openSide percentVisible: 1.0 ];
424431 [self .centerViewController beginAppearanceTransition: YES animated: animated];
425432 [self
@@ -433,11 +440,8 @@ -(void)setCenterViewController:(UIViewController *)newCenterViewController withC
433440 }];
434441 }
435442 else {
436- [self .centerViewController beginAppearanceTransition: YES animated: NO ];
437- [self .centerViewController endAppearanceTransition ];
438- [self .centerViewController didMoveToParentViewController: self ];
439443 if (completion) {
440- completion (NO );
444+ completion (YES );
441445 }
442446 }
443447}
0 commit comments