Skip to content

Commit

Permalink
Prevent several rotation methods from getting called twice in iOS8, w…
Browse files Browse the repository at this point in the history
…here they are automatically called from [UIViewController viewWillTransitionToSizeWithTransitionCoordinator:]
  • Loading branch information
Arie Litovsky authored and kcharwood committed Mar 17, 2015
1 parent 18b4a56 commit ed3d0b4
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions MMDrawerController/MMDrawerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,13 @@ -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrien
[self resetDrawerVisualStateForDrawerSide:self.openSide];
}
}
for(UIViewController * childViewController in self.childViewControllers){
[childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if ([self needsManualForwardingOfRotationEvents])
{
for(UIViewController * childViewController in self.childViewControllers){
[childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
}

}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
Expand All @@ -789,8 +793,12 @@ -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInter
CFRelease(oldShadowPath);
}
}
for(UIViewController * childViewController in self.childViewControllers){
[childViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];

if ([self needsManualForwardingOfRotationEvents])
{
for(UIViewController * childViewController in self.childViewControllers){
[childViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
}
}

Expand All @@ -801,8 +809,12 @@ -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfac
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
self.startingPanRect = self.centerContainerView.frame; //
for(UIViewController * childViewController in self.childViewControllers){
[childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];

if ([self needsManualForwardingOfRotationEvents])
{
for(UIViewController * childViewController in self.childViewControllers){
[childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
}

Expand Down Expand Up @@ -1354,6 +1366,12 @@ -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveT
}
}

- (BOOL)needsManualForwardingOfRotationEvents
{
BOOL beforeIOS8 = ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending);
return beforeIOS8;
}

#pragma mark Gesture Recogizner Delegate Helpers
-(MMCloseDrawerGestureMode)possibleCloseGestureModesForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer withTouch:(UITouch*)touch{
CGPoint point = [touch locationInView:self.childControllerContainerView];
Expand Down

0 comments on commit ed3d0b4

Please sign in to comment.