开发者

iOS 4.0 contentScaleFactor and scale - how to handle in 3.1.3?

开发者 https://www.devze.com 2023-01-25 01:08 出处:网络
I am tasked wi开发者_如何学JAVAth making an app that works in iOS 4.0 work in 3.1.3 and 3.2 again. Mostly it is straightforward but the handling of the new API for scale and other situations where val

I am tasked wi开发者_如何学JAVAth making an app that works in iOS 4.0 work in 3.1.3 and 3.2 again. Mostly it is straightforward but the handling of the new API for scale and other situations where values must be passed/returned is hard.

respondsToSelector/performSelector takes care of nearly everything else.

Here's a simplified version of what is going on:

-(float)getImageScaleFactor 
{
  if([[UIScreen mainScreen] scale == 2.0)
      return kScaleFactorForRetinaDisplay;
  else
      return kScaleFactorForOlderDisplay;
}

scale isn't in iOS prior to 4.0.

Can anyone show a code sample that will work in all versions of iOS?


I use very similar code, but you're missing one important part: respondsToSelector:

if([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [UIScreen mainScreen].scale == 2.0f)
    return kScaleFactorForRetinaDisplay;
else
    return kScaleFactorForOlderDisplay;
0

精彩评论

暂无评论...
验证码 换一张
取 消