Pages

Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

Monday, August 26, 2013

Check iPhone or iPad by Code in Xcode

To Check iPhone or iPad view by Code, we can check by following code


if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    // Code for iPhone View

} else {
    // Code for iPad View
}


Now to Check iPhone5 or iPhone4, we can do a check in iPhone vide code

-(Boolean)checkIphone5{
    UIScreen *screen = [UIScreen mainScreen];
    CGRect fullScreenRect = screen.bounds;
    if (fullScreenRect.size.height==568) {
        return TRUE;
    }
    else{
        return FALSE;
    }
}

and We can use this as like below


if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
   if ([self checkIphone5]) {

      // Code for iPhone5 View
   }
   else
   {
      // Code for iPhone 4 View
   }
else {

    // Code for iPad View
}