How to check iPhone Device Version in iOS?

后端 未结 5 1725
长情又很酷
长情又很酷 2021-01-01 04:46

Hi i would like to check iPhone Device Version in iOS.

I mean , currently running device is iPhone 4 or iPhone 5.

I need to check the device , is that iPhone

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 05:31

    Add This Macros to your code:

    #define HEIGHT_IPHONE_5 568
    #define IS_IPHONE   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    #define IS_IPHONE_5 ([[UIScreen mainScreen] bounds ].size.height == HEIGHT_IPHONE_5 )
    

    then just check whenever you needs..

    if (IS_IPHONE_5) {
        //Code for iPhone5
    }else{
        //Code for earlier version
    }
    

提交回复
热议问题