how to know is it iphone or ipad?

后端 未结 5 836
北荒
北荒 2021-01-06 07:35

i want to know the user uses the iphone or ipad,if the user uses the iphone i want to open the camera,if he uses the ipad or runs in simulator i want to open the library. ho

5条回答
  •  时光取名叫无心
    2021-01-06 07:36

    Make use of this to identify devices.

    // If iPhoneOS is 3.2 or greater then __IPHONE_3_2 will be defined
    #ifndef __IPHONE_3_2    
    
    typedef enum {
        UIUserInterfaceIdiomPhone,           // iPhone and iPod touch
        UIUserInterfaceIdiomPad,             // iPad
    } UIUserInterfaceIdiom;
    
    #define UI_USER_INTERFACE_IDIOM() UIUserInterfaceIdiomPhone
    
    #endif // ifndef __IPHONE_3_2
    

    but if you want to check if camera is available I think you can make use of UIImagePickerController's static method

    + (BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType
    

提交回复
热议问题