Skip to content

Commit

Permalink
Merge pull request mutualmobile#240 from mutualmobile/center-view-con…
Browse files Browse the repository at this point in the history
…tainer-double-call

Fixing double center container view being created and added to view heir...
  • Loading branch information
kcharwood committed Apr 15, 2014
2 parents fd92624 + e6e2c87 commit b291792
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions MMDrawerController/MMDrawerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,28 @@ -(void)setCenterViewController:(UIViewController *)centerViewController animated
if ([self.centerViewController isEqual:centerViewController]) {
return;
}

if (_centerContainerView == nil) {
//This is related to Issue #152 (https://github.com/mutualmobile/MMDrawerController/issues/152)
// also fixed below in the getter for `childControllerContainerView`. Turns out we have
// two center container views getting added to the view during init,
// because the first request self.centerContainerView.bounds was kicking off a
// viewDidLoad, which caused us to be able to fall through this check twice.
//
//The fix is to grab the bounds, and then check again that the child container view has
//not been created.

CGRect centerFrame = self.childControllerContainerView.bounds;
if(_centerContainerView == nil){
_centerContainerView = [[MMDrawerCenterContainerView alloc] initWithFrame:self.childControllerContainerView.bounds];
_centerContainerView = [[MMDrawerCenterContainerView alloc] initWithFrame:centerFrame];
[self.centerContainerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[self.centerContainerView setBackgroundColor:[UIColor clearColor]];
[self.centerContainerView setOpenSide:self.openSide];
[self.centerContainerView setCenterInteractionMode:self.centerHiddenInteractionMode];
[self.childControllerContainerView addSubview:self.centerContainerView];
}

}

UIViewController * oldCenterViewController = self.centerViewController;
if(oldCenterViewController){
if(animated == NO){
Expand Down

0 comments on commit b291792

Please sign in to comment.