Problem adapting scale factor for iPad x2 compatibility mode

情到浓时终转凉″ 提交于 2019-12-06 12:51:22

问题


I wonder if anyone can help me with following. I have written a Quartz 2d ap and have used the following code to get the correct scale factor for each device :

if ([UIScreen instancesRespondToSelector:@selector(scale)])
{
        return [[UIScreen mainScreen] scale];
}
else
{
        return 1.0;
}

I then multiply all values by this scale mulitplier in my code. The problem I have is that the app does not display propertly in x2 mode on the ipad - everything is two times too big. Can anybody help me ?

Thanks,

Martin


回答1:


The scale factor is related to the Retina displays on the newer iPhones and iPod touches, not the 2X scaling setting on the iPad. In fact, the UIScreen scale property you are referencing does not exist on the iPad's current 3.2 OS version, only on 4.0+. On the current iPads running the OS 4.2 beta, it should always return 1.0.

The problem you are experiencing with Quartz drawing in the 2X mode must come from somewhere else. Do you do any device-specific checks for any elements in your code?




回答2:


I am not sure if this is your problem, but you seem to want to test the UIScreen for the selector scale. Which it will never have. That selector works only on [UIScreen mainScreen].

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
{
     return [[UIScreen mainScreen] scale];
}
else    
{
     return 1.0;
}

Although, this mistake would let you think that it would always return a scale of 1.0.



来源:https://stackoverflow.com/questions/3873868/problem-adapting-scale-factor-for-ipad-x2-compatibility-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!