-1

I am developing an Application for iphone. I am using xib for design screens. How can i make this application for iPhone 5 and iphone 4s. Please help me on that reply with example.

Thanks

BhavikKama
  • 8,566
  • 12
  • 94
  • 164
alok kumar
  • 43
  • 5
  • whts the Ipad tag doing here???your question doesn't seem that you have asked something related to ipad? – BhavikKama Oct 08 '13 at 10:40
  • possible duplicate of [How to develop or migrate apps for iPhone 5 screen resolution?](http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution) – BhavikKama Oct 08 '13 at 10:41

3 Answers3

0

you need two design two xib files one with 3.5 inch retina(iphone 4) and another is for 4 inch retina(iphone 5) and when you call that xib you need to check condition.

#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE
#define isiPhone4  ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE

define above stattement in constant.h file

and then check following condition in your view controller when you push or change viewcontroller

if (isiPhone5) // check wheather a phone is iphone 5 or not
{

    yourViewController *objyourViewController=[[yourViewController   alloc]initWithNibName:@"yourViewController_iphone5" bundle:nil];
    [self.navigationController pushViewController:objyourViewController animated:YES];
}
else if (isiPhone4) // check wheather a phone is iphone 4 or not
{
    yourViewController *objyourViewController=[[yourViewController alloc]initWithNibName:@"yourViewController_iphone4" bundle:nil];
    [self.navigationController pushViewController:objyourViewController animated:YES];
}

I hope this will help you

Maul
  • 1,179
  • 6
  • 13
0

Check In Xib ..enter image description here

Only Upper and left Part enable ..then try it..

Bajaj
  • 859
  • 7
  • 17
0

There are three method for UI adjustment for different resolution device

1)---------------------------------First method-------------------------------------------

-(int)setScreenOf
    {   
        if([self isPad])
        {
            //return value 
            //code for ipad
        }
        else
        {        
            CGRect screenBounds = [[UIScreen mainScreen] bounds];
            if (screenBounds.size.height ==568) //height can be dynamic as per device
            {
                 //return value
                // code for 4-inch screen           
            }
            else
            {    //return value
                // code for 3.5-inch screen           
            }  
        }

    }

2)-----------------------------------second method-------------------------

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE

you can make different xib for different device and navigate app according to that.

    if(IS_IPAD)
        { 
            startVc=[[Start alloc]initWithNibName:@"start_ipad" bundle:nil];
            //xib For ipad
        }
        else
        {
            if(isiPhone5 )
            {
                startVc=[[Start alloc]initWithNibName:@"start_iphone" bundle:nil];
                //xib for iphone5
            }
            else
            {
                startVc=[[Start alloc]initWithNibName:@"Start" bundle:nil]; 
                //xib for 3.5 inch device
            }

        }

nav=[[UINavigationController alloc]initWithRootViewController:startVc];

3)-------------------------------------Third method-----------------

you can use single xib for different device,but it will become complex to manage if your ui contain to much images.

enter image description here

you can adjust your UI Control OR Re-size your Control Using this authorize property. how your UI-Control will take effect will be shown by Example window beside it.

  1. The Inner Arrow will Make your UI Control small and large as per device resolution
  2. The outer bound will hold down your control at specific corner on center.
utkal patel
  • 1,321
  • 1
  • 15
  • 24