From a7ac78bf28d6b48bd23da7628c82ae935157649e Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Wed, 29 Jan 2014 14:43:38 -0600 Subject: [PATCH] Fixing issue where appearance methods were correctly handled for center view controller (#139) --- MMDrawerController/MMDrawerController.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MMDrawerController/MMDrawerController.m b/MMDrawerController/MMDrawerController.m index b8a329c0..101a0b5b 100644 --- a/MMDrawerController/MMDrawerController.m +++ b/MMDrawerController/MMDrawerController.m @@ -378,6 +378,8 @@ -(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity: } #pragma mark - Updating the Center View Controller +//If animated is NO, then we need to handle all the appearance calls within this method. Otherwise, +//let the method calling this one handle proper appearance methods since they will have more context -(void)setCenterViewController:(UIViewController *)centerViewController animated:(BOOL)animated{ if(_centerContainerView == nil){ _centerContainerView = [[MMDrawerCenterContainerView alloc] initWithFrame:self.childControllerContainerView.bounds]; @@ -417,9 +419,14 @@ -(void)setCenterViewController:(UIViewController *)centerViewController animated } -(void)setCenterViewController:(UIViewController *)newCenterViewController withCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{ + + if(self.openSide == MMDrawerSideNone){ + //If a side drawer isn't open, there is nothing to animate... + animated = NO; + } [self setCenterViewController:newCenterViewController animated:animated]; - if(self.openSide != MMDrawerSideNone){ + if(animated){ [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:1.0]; [self.centerViewController beginAppearanceTransition:YES animated:animated]; [self @@ -433,11 +440,8 @@ -(void)setCenterViewController:(UIViewController *)newCenterViewController withC }]; } else { - [self.centerViewController beginAppearanceTransition:YES animated:NO]; - [self.centerViewController endAppearanceTransition]; - [self.centerViewController didMoveToParentViewController:self]; if(completion) { - completion(NO); + completion(YES); } } }