Checking the device is ipad or iPhone in univercial application


Below method is the utility method to check whether device is ipad or iphone while devloping universial application.Which works in even IOS 3.0

+(BOOL)isDeviceAniPad
{
        #ifdef UI_USER_INTERFACE_IDIOM()
              return UI_USER_INTERFACE_IDIOM();
        #else
            return NO;
      #endif
}

2 comments:

  1. jack:- nice peace of code

    ReplyDelete
  2. won't work, return UI_USER_INTERFACE_IDIOM(); does not return a BOOL value, u should use return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad

    ReplyDelete