From 69294dae1352d5032a503f60d8d563559d6465f3 Mon Sep 17 00:00:00 2001 From: Inferis Date: Thu, 2 Feb 2012 22:08:56 +0100 Subject: [PATCH] shouldAutorotateToInterfaceOrientation now takes modalViewControllers into consideration. Fixes #28. --- ViewDeck/IIViewDeckController.m | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ViewDeck/IIViewDeckController.m b/ViewDeck/IIViewDeckController.m index b6f7c12f..b0a27efb 100644 --- a/ViewDeck/IIViewDeckController.m +++ b/ViewDeck/IIViewDeckController.m @@ -404,19 +404,27 @@ - (void)viewDidDisappear:(BOOL)animated { - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { _preRotationWidth = self.referenceBounds.size.width; - + if (self.rotationBehavior == IIViewDeckRotationKeepsViewSizes) { _leftWidth = self.leftController.view.frame.size.width; _rightWidth = self.rightController.view.frame.size.width; } - if (self.centerController) { - // let the center controller handle the rotation behavior - BOOL should = [self.centerController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; - return should; - } - - return YES; + // heads up to @schemers for accounting with the modal views. + // see: https://github.com/Inferis/ViewDeck/issues/28 + + // let the viewdeckcontroller modalViewController handle the rotation behavior + UIViewController* rotateController = self.modalViewController; + // or, let the center controller modalViewController handle the rotation behavior + if (!rotateController) rotateController = self.centerController.modalViewController; + // or, let the center controller handle the rotation behavior + if (!rotateController) rotateController = self.centerController; + + BOOL should = YES; + if (rotateController) + should = [rotateController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; + + return should; } - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {