Is there a way to detect that your iPhone app us running 2x/1x on an iPad?
I need to be able to detect the difference in points per inch for my app.
If there is a large circle enclosed in a grey box that appears as an overlay on your iPhone screen, your phone's AssistiveTouch feature is enabled.
How to remove a control. Go to Settings > Control Center. Tap the Remove button , then tap Remove next to the app or feature that you want to remove.
Check the scale
property:
[[UIScreen mainScreen] scale]
Here's a handy function:
+(BOOL) screenIs2xResolution {
return 2.0 == [MyDeviceClass mainScreenScale];
}
+(CGFloat) mainScreenScale {
CGFloat scale = 1.0;
UIScreen* screen = [UIScreen mainScreen];
if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
scale = [screen scale];
}
return scale;
}
Credits: http://www.markj.net/iphone-4-2x-graphics-scale-ipad/
See also: http://struct.ca/2010/high-res-graphics-in-cocos2d/
Since you cannot register for _UIClassicApplicationWillChangeZoomNotificationName
, it seems to be an internal constant, what I did is:
Register for any Notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeZoom:) name:nil object:nil];
And then check the according values:
- (void)changeZoom:(NSNotification*)notification
{
if ([[notification name] isEqualToString:@"_UIClassicApplicationWillChangeZoomNotificationName"])
{
NSLog(@"Zoom changed to %@", [[[notification userInfo] objectForKey:@"_UIClassicIsZoomedUserInfoKeyName"] boolValue] == 0 ? @"1x" : @"2x");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With