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-8484] Ignore orientation if we are not the keywindow #1991

Merged
merged 2 commits into from
Apr 14, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions iphone/Classes/TiApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ TI_INLINE void waitForMemoryPanicCleared() //WARNING: This must never be run o

+(TiContextGroupRef)contextGroup;

-(BOOL)windowIsKeyWindow:(UIWindow*)window_;

-(void)attachXHRBridgeIfRequired;

/**
Expand Down
5 changes: 5 additions & 0 deletions iphone/Classes/TiApp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ -(void)initController
[window makeKeyAndVisible];
}

-(BOOL)windowIsKeyWindow:(UIWindow*)window_
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be faster if the function returned [window isKeyWindow]. This also removes the need of an argument.

return (window == window_);
}

-(void)attachXHRBridgeIfRequired
{
#ifdef USE_TI_UIWEBVIEW
Expand Down
11 changes: 10 additions & 1 deletion iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,16 @@ -(BOOL)isModal {
return modalFlag;
}
-(void)refreshOrientationWithDuration:(NSTimeInterval) duration
{ /*
{
if ([[[UIApplication sharedApplication] windows] count] > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a lot of extra checks. Couldn't it just be a single if(![[TiApp app] windowIsKeyWindow])? The reason is that getting the windows array requires a memory copy that can be sidestepped.

//Short circuit the whole thing if I am not key window
if (![[TiApp app] windowIsKeyWindow:[[UIApplication sharedApplication] keyWindow]]) {
VerboseLog(@"[DEBUG] RETURNING BECAUSE WE ARE NOT KEY WINDOW");
return;
}
}

/*
* Apple gives us a wonderful method, attemptRotation... in iOS 5 below
* but sadly, it only updates the orientation if the UI can change that
* way. So we give it a shot, and if that's not enough, consult the
Expand Down