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
您需要两个设计两个 xib 文件,一个带有 3.5 英寸视网膜(iphone 4),另一个用于 4 英寸视网膜(iphone 5),当您调用该 xib 时,您需要检查条件。
#define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE
#define isiPhone4 ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE
在 constant.h 文件中定义上述语句
然后在您推送或更改视图控制器时检查视图控制器中的以下条件
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];
}
我希望这能帮到您
签入 Xib ..
只有上和左部分启用..然后尝试..
不同分辨率设备的UI调整有3种方法
1)---------------------------------第一种方法------------- ------------------------------
-(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)------------------------第二种方法---------- --------------
#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)--------------------------第三种方法--------- --------
您可以将单个 xib 用于不同的设备,但是如果您的 ui 包含太多图像,则管理起来会变得复杂。
您可以使用此授权属性调整您的 UI 控件或重新调整控件的大小。您的 UI-Control 将如何生效将由旁边的示例窗口显示。