Skip to content

@fzwo /sevenInchAppDelegate.m
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simulating a 7.85 inch iPad
//Put this into your AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Your app launch code here...
[self.window makeKeyAndVisible];
[self simulateSevenInchIpad];
return YES;
}
- (void)simulateSevenInchIpad
{
//simulate 7.85 inch iPad
//scale window
CGFloat scaleFactor = 7.85/9.7; //try 768.0/1024.0 for the size of two apps on a 10" iPad side by side!;
self.window.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
//we also want to scale the keyboard
[[NSNotificationCenter defaultCenter] addObserver:self
selector:(transformKeyboardForSevenInchIpadSimulation)
name:UIKeyboardWillChangeFrameNotification];
}
- (void)transformKeyboardForSevenInchIpadSimulation
{
//finding the window that hosts the keyboard - from http://stackoverflow.com/a/6457567/534888
for (UIWindow *window in [[UIApplication sharedApplication] windows]) {
if (![window.class isEqual:UIWindow.class]) {
//keyboard window found... probably
CGAffineTransform identityTransformUpsideDown = CGAffineTransformMakeRotation(M_PI);
CGAffineTransform identityTransformRotatedLeft = CGAffineTransformMake(0, 1, -1, 0, -128, 128);
CGAffineTransform identityTransformRotatedRight = CGAffineTransformMake(0, -1, 1, 0, -128, 128);
//if the window is unscaled, scale it
if (CGAffineTransformIsIdentity(window.transform)
|| CGAffineTransformEqualToTransform(identityTransformUpsideDown, window.transform)
|| CGAffineTransformEqualToTransform(identityTransformRotatedLeft, window.transform)
|| CGAffineTransformEqualToTransform(identityTransformRotatedRight, window.transform))
{
CGFloat scaleFactor = 7.85/9.7; //768.0/1024.0;
window.transform = CGAffineTransformScale(window.transform, scaleFactor, scaleFactor);
}
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.