Best way to programmatically detect iPad/iPhone hardware

前端 未结 10 936
借酒劲吻你
借酒劲吻你 2020-11-27 14:14

The reason I need to find out is that on an iPad, a UIPickerView has the same height in landscape orientation as it does in portrait. On an iPhone it is different. The iPad

10条回答
  •  旧时难觅i
    2020-11-27 14:50

    My solution (works on 3.2+):

    #define IS_IPHONE (!IS_IPAD)
    #define IS_IPAD (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone)
    

    then,

    if (IS_IPAD)
        // do something
    

    or

    if (IS_IPHONE)
        // do something else
    

提交回复
热议问题