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
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
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
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.
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.