Skip to content

Commit

Permalink
TIMOB-4137 We must delay rotating the status bar when returning from …
Browse files Browse the repository at this point in the history
…a modal until after the modal animation is done.
  • Loading branch information
Blain Hamon committed Jun 22, 2011
1 parent c6d728b commit adcd74e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions iphone/Classes/TiApp.mm
Expand Up @@ -220,8 +220,7 @@ - (void)loadSplash
if (!loaded) {
[self attachSplash];
}
[window addSubview:controller.view];

[window setRootViewController:controller];
[window makeKeyAndVisible];
}

Expand Down
3 changes: 3 additions & 0 deletions iphone/Classes/TiRootViewController.h
Expand Up @@ -22,6 +22,7 @@

UIInterfaceOrientation lastOrientation;
UIInterfaceOrientation windowOrientation;
BOOL ignoreRotations;

NSMutableArray * viewControllerStack;
BOOL isCurrentlyVisible;
Expand Down Expand Up @@ -65,4 +66,6 @@
- (void)openWindow:(TiWindowProxy *)window withObject:(id)args;
- (void)closeWindow:(TiWindowProxy *)window withObject:(id)args;

-(UIInterfaceOrientation)mostRecentlyAllowedOrientation;

@end
17 changes: 11 additions & 6 deletions iphone/Classes/TiRootViewController.m
Expand Up @@ -199,14 +199,21 @@ - (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];
}

- (void) viewDidDisappear:(BOOL)animated
{
ignoreRotations = YES;
isCurrentlyVisible = NO;
[self.view resignFirstResponder];
[super viewDidDisappear:animated];
Expand Down Expand Up @@ -238,19 +245,17 @@ -(void)repositionSubviews

-(void)manuallyRotateToOrientation:(UIInterfaceOrientation)newOrientation duration:(NSTimeInterval)duration
{
if (ignoreRotations) {
return;
}

UIApplication * ourApp = [UIApplication sharedApplication];
if (newOrientation != [ourApp statusBarOrientation])
{
[keyboardFocusedProxy blur:nil];
[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;

Expand Down

0 comments on commit adcd74e

Please sign in to comment.