2

Its easy to check whether device is iPhone 5 or iPhone, by checking its height, as given below

if([UIScreen mainScreen].bounds.size.height == 568){
    // iPhone 5
} else{
    // Regular iPhone
}

However, I want to know, after coming in else body 480 height , I want to check whether its iPhone or iPhone retina?

How can do that?

My main target is to set navigation, as given in my another question

iOS XIB

Thanks

Community
  • 1
  • 1
Duaan
  • 609
  • 1
  • 13
  • 29
  • 1
    What do you mean when you say "iPhone" without any qualifications? – Matt Ball Sep 17 '13 at 05:17
  • What is the ultimate problem are you trying to solve? Are you trying to lay out your views? You should be able to use auto layout or springs and struts to handle that. Are you trying to load different image assets? iOS handles that detail for you. Are you trying to do something else? – BergQuester Sep 17 '13 at 05:23
  • @BergQuester, Dear, I am stuck at iOS different xib and screens. YOu guided me before, but also by Using AutoSize, I couldn't able to make same xib for iPhone4 and iPhone5 and iPhone without ratina. – Duaan Sep 17 '13 at 05:28
  • @BergQuester, can you see old question, which you answer. this is link http://stackoverflow.com/questions/17938427/xib-for-different-ios-devices-simulator – Duaan Sep 17 '13 at 05:29
  • Ah yes, I remember now. It's quite easy to have the same xib for all iPhones. Just follow what people were telling you in the other question. By having three different xibs for three different phone models, you're just creating more work for yourself and making it harder to maintain your application. – BergQuester Sep 17 '13 at 05:33
  • You are right, but when we talk about quality, the exact same clone of DESIGN, so we have to make different xib, as AutoSize creates gap between button and other small changes in Screen. It doesn't give same result. – Duaan Sep 17 '13 at 05:42
  • Tell you what, post a link here to a mockup of the screen you're implementing and I'll give it a shot at implementing a single xib in the next couple of weeks. I'll try to keep track of the steps to do it. I won't do any logic or data code, just layout. – BergQuester Sep 17 '13 at 05:46

4 Answers4

7

If you really need this, you can use something like this:

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
    if ([[UIScreen mainScreen] scale] >= 2.0) {
        // retina
    }
    else {
        // not retina
    }
}
Denis Kozhukhov
  • 1,205
  • 8
  • 16
3

Define as macro in pch file as below

#define IS_RETINA ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && ([UIScreen mainScreen].scale == 2.0))
Prasad_R
  • 557
  • 2
  • 11
1

I guess you have to check whether the screen responds to the scale message and its value is 2.0

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]
    && 
    [[UIScreen mainScreen] scale] == 2.0) 
{
    //Retina
} 
else 
{
    //Not Retina
}
rano
  • 5,616
  • 4
  • 40
  • 66
1

Use this method..

Return YES it means its retina otherwise non-retina,

+(BOOL)iPhoneRetina
{
    return ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0) ;
}
Dharmbir Singh
  • 17,485
  • 5
  • 50
  • 66