From adcd74e411d6994d3362003217493b4c748ce126 Mon Sep 17 00:00:00 2001 From: Blain Hamon Date: Wed, 22 Jun 2011 16:30:56 -0700 Subject: [PATCH] TIMOB-4137 We must delay rotating the status bar when returning from a modal until after the modal animation is done. --- iphone/Classes/TiApp.mm | 3 +-- iphone/Classes/TiRootViewController.h | 3 +++ iphone/Classes/TiRootViewController.m | 17 +++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/iphone/Classes/TiApp.mm b/iphone/Classes/TiApp.mm index cbd61febe10..8f55772a323 100644 --- a/iphone/Classes/TiApp.mm +++ b/iphone/Classes/TiApp.mm @@ -220,8 +220,7 @@ - (void)loadSplash if (!loaded) { [self attachSplash]; } - [window addSubview:controller.view]; - + [window setRootViewController:controller]; [window makeKeyAndVisible]; } diff --git a/iphone/Classes/TiRootViewController.h b/iphone/Classes/TiRootViewController.h index 26d9152661b..55b1c0f5646 100644 --- a/iphone/Classes/TiRootViewController.h +++ b/iphone/Classes/TiRootViewController.h @@ -22,6 +22,7 @@ UIInterfaceOrientation lastOrientation; UIInterfaceOrientation windowOrientation; + BOOL ignoreRotations; NSMutableArray * viewControllerStack; BOOL isCurrentlyVisible; @@ -65,4 +66,6 @@ - (void)openWindow:(TiWindowProxy *)window withObject:(id)args; - (void)closeWindow:(TiWindowProxy *)window withObject:(id)args; +-(UIInterfaceOrientation)mostRecentlyAllowedOrientation; + @end diff --git a/iphone/Classes/TiRootViewController.m b/iphone/Classes/TiRootViewController.m index 5a7db06bc85..8f90044b874 100644 --- a/iphone/Classes/TiRootViewController.m +++ b/iphone/Classes/TiRootViewController.m @@ -199,7 +199,13 @@ - (void)viewWillDisappear:(BOOL)animated; // Called when the view is dismissed, - (void) viewDidAppear:(BOOL)animated { + ignoreRotations = NO; [self.view becomeFirstResponder]; + CGFloat duration = 0.0; + if (animated) { + duration = [[UIApplication sharedApplication] statusBarOrientationAnimationDuration]; + } + [self manuallyRotateToOrientation:[self mostRecentlyAllowedOrientation] duration:duration]; [super viewDidAppear:animated]; VerboseLog(@"%@%@",self,CODELOCATION); [[viewControllerStack lastObject] viewDidAppear:animated]; @@ -207,6 +213,7 @@ - (void) viewDidAppear:(BOOL)animated - (void) viewDidDisappear:(BOOL)animated { + ignoreRotations = YES; isCurrentlyVisible = NO; [self.view resignFirstResponder]; [super viewDidDisappear:animated]; @@ -238,6 +245,10 @@ -(void)repositionSubviews -(void)manuallyRotateToOrientation:(UIInterfaceOrientation)newOrientation duration:(NSTimeInterval)duration { + if (ignoreRotations) { + return; + } + UIApplication * ourApp = [UIApplication sharedApplication]; if (newOrientation != [ourApp statusBarOrientation]) { @@ -245,12 +256,6 @@ -(void)manuallyRotateToOrientation:(UIInterfaceOrientation)newOrientation durati [ourApp setStatusBarOrientation:newOrientation animated:(duration > 0.0)]; [keyboardFocusedProxy focus:nil]; } - - // if already in the orientation, don't do it again - if (lastOrientation==newOrientation) - { - return; - } CGAffineTransform transform;