Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17712] iOS8: Avoid race condition on dismissal of modal window #6204

Merged
merged 2 commits into from
Oct 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions iphone/Classes/TiRootViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
-(void)incrementActiveAlertControllerCount;
-(void)decrementActiveAlertControllerCount;
-(UIViewController*)topPresentedController;
-(UIInterfaceOrientation) lastValidOrientation:(TiOrientationFlags)orientationFlags;
-(void)updateStatusBar;
@property (nonatomic, readonly) BOOL statusBarInitiallyHidden;
@property (nonatomic, readonly) UIStatusBarStyle defaultStatusBarStyle;
Expand Down
24 changes: 12 additions & 12 deletions iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1015,18 +1015,19 @@ -(void)repositionSubviews
*/
}

-(UIInterfaceOrientation) lastValidOrientation:(BOOL)checkModal
-(UIInterfaceOrientation) lastValidOrientation:(TiOrientationFlags)orientationFlags
{
if ([self shouldRotateToInterfaceOrientation:deviceOrientation checkModal:checkModal]) {
if (TI_ORIENTATION_ALLOWED(orientationFlags,deviceOrientation)) {
return deviceOrientation;
}
for (int i = 0; i<4; i++) {
if ([self shouldRotateToInterfaceOrientation:orientationHistory[i] checkModal:checkModal]) {
return orientationHistory[i];
}
}
//This line should never happen, but just in case...
return UIInterfaceOrientationPortrait;
if (TI_ORIENTATION_ALLOWED(orientationFlags,orientationHistory[i])) {
return orientationHistory[i];
}
}

//This line should never happen, but just in case...
return UIInterfaceOrientationPortrait;
}

- (BOOL)shouldRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation checkModal:(BOOL)check
Expand Down Expand Up @@ -1185,7 +1186,7 @@ - (NSUInteger)supportedInterfaceOrientations{

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self lastValidOrientation:YES];
return [self lastValidOrientation:[self getFlags:NO]];
}

-(void)didOrientNotify:(NSNotification *)notification
Expand All @@ -1196,7 +1197,6 @@ -(void)didOrientNotify:(NSNotification *)notification
return;
}
deviceOrientation = (UIInterfaceOrientation) newOrientation;

if ([self shouldRotateToInterfaceOrientation:deviceOrientation checkModal:NO]) {
[self resetTransformAndForceLayout:YES];
[self updateOrientationHistory:deviceOrientation];
Expand All @@ -1215,7 +1215,7 @@ -(void)refreshOrientationWithDuration:(id)unused
return;
}

UIInterfaceOrientation target = [self lastValidOrientation:NO];
UIInterfaceOrientation target = [self lastValidOrientation:[self getFlags:NO]];
//Device Orientation takes precedence.
if (target != deviceOrientation) {
if ([self shouldRotateToInterfaceOrientation:deviceOrientation checkModal:NO]) {
Expand Down Expand Up @@ -1541,7 +1541,7 @@ -(void)viewDidAppear:(BOOL)animated
for (id<TiWindowProtocol> thisWindow in containedWindows) {
[thisWindow viewDidAppear:animated];
}
if (forcingRotation) {
if (forcingRotation || [TiUtils isIOS8OrGreater]) {
forcingRotation = NO;
[self performSelector:@selector(childOrientationControllerChangedFlags:) withObject:[containedWindows lastObject] afterDelay:[[UIApplication sharedApplication] statusBarOrientationAnimationDuration]];
} else {
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (NSUInteger)supportedInterfaceOrientations {

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[[TiApp app] controller] preferredInterfaceOrientationForPresentation];
return [[[TiApp app] controller] lastValidOrientation:_supportedOrientations];
}

-(void)loadView
Expand Down