Created
October 28, 2012 13:27
-
-
Save vgrichina/3968594 to your computer and use it in GitHub Desktop.
iPad mini simulation hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
// Some other stuff here ... | |
CGFloat scale = 4.71f/5.82f; | |
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scale, scale); | |
self.window.transform = CGAffineTransformConcat(scaleTransform, self.window.transform); | |
self.window.clipsToBounds = YES; | |
[self statusBarChanged:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(statusBarChanged:) | |
name:UIApplicationDidChangeStatusBarOrientationNotification | |
object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification | |
object:nil]; | |
return YES; | |
} | |
- (void)statusBarChanged:(NSNotification *)note { | |
CGFloat scale = 4.71f/5.82f; | |
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scale, scale); | |
UIWindow *statusBarWindow = (UIWindow *)[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"]; | |
statusBarWindow.transform = CGAffineTransformConcat(scaleTransform, statusBarWindow.transform); | |
} | |
- (void)keyboardWillShow:(NSNotification *)note { | |
[self performSelector:(@selector(doMagicToKeyboard)) withObject:nil afterDelay:0]; | |
} | |
-(void)doMagicToKeyboard { | |
for (UIWindow *window in [[UIApplication sharedApplication] windows]) { | |
[self checkForKeyboard:window]; | |
} | |
} | |
- (void)checkForKeyboard:(UIView *)view { | |
static BOOL didIt = NO; | |
for (UIView *currentView in view.subviews) { | |
if(([[currentView description] hasPrefix:@"<UIKeyboard"] == YES) && !didIt) | |
{ | |
didIt = YES; | |
UIView *thisView = currentView.superview.superview; | |
thisView.clipsToBounds = YES; | |
CGFloat scale = 4.71f/5.82f; | |
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scale, scale); | |
thisView.transform = CGAffineTransformConcat(scaleTransform, thisView.transform); | |
} else { | |
[self checkForKeyboard:currentView]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment