Skip to content

Instantly share code, notes, and snippets.

@vgrichina
Created October 28, 2012 13:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgrichina/3968594 to your computer and use it in GitHub Desktop.
Save vgrichina/3968594 to your computer and use it in GitHub Desktop.
iPad mini simulation hack
- (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