【发布时间】:2014-01-10 09:06:41
【问题描述】:
我有 4 个 xib,其中两个 xib 用于 ios7,另一个用于 ios6。我没有使用自动布局,我的应用程序在 3.5 英寸和 4 英寸的 ios 7 上运行良好,但是当我运行应用程序时出现问题ios6.i根据ios版本区分代码。
当应用程序启动时,它的导航栏在某个底部,如果我单击另一个选项卡并再次返回两个,我的第一个选项卡导航栏处于其完美的一侧。我静态地使用导航栏。
这是我点击 tabitem 时的一个视图控制器的代码
NSLog(@"Iphone %f ",\[\[UIScreen mainScreen\] bounds\].size.height);
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
{
//The version of the device is iOS7.0 or higher.
if (IS_IPHONE_5) {
_HomeViewController_obj = \[\[_HomeViewController alloc\] initWithNibName:@"4HomeViewController" bundle:nil\];
} else {
_HomeViewController_obj = \[\[_HomeViewController alloc\] initWithNibName:@"4HomeViewController_iphone4" bundle:nil\];
}
//call controller with ios7 xib here
}
else
{
//The version of the device is lower then iOS7.0.
if (IS_IPHONE_5) {
_HomeViewController_obj = \[\[_HomeViewController alloc\] initWithNibName:@"4HomeViewController_iphone5" bundle:nil\];
} else {
_HomeViewController_obj = \[\[_HomeViewController alloc\] initWithNibName:@"4HomeViewController_iphoneOld" bundle:nil\];
}
//call controller with ios6 xib here
}
if(\[UIDevice currentDevice\].userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
NSLog(@"Ipad ");
}
else
{
NSLog(@"Iphone %f ",\[\[UIScreen mainScreen\] bounds\].size.height);
if (\[\[UIScreen mainScreen\] bounds\].size.height == 568) {
\[btn1 setFrame:CGRectMake(15, 525, 30, 40)\];
\[btn2 setFrame:CGRectMake(80, 525, 30, 40)\];
\[btn3 setFrame:CGRectMake(140, 525, 30, 40)\];
\[btn4 setFrame:CGRectMake(205, 522, 45, 45)\];
\[btn5 setFrame:CGRectMake(275, 525, 30, 40)\];
} else {
\[self.view setFrame:CGRectMake(0,0, 320, 480)\];
\[btn1 setFrame:CGRectMake(15, 436,40, 40)\];
\[btn2 setFrame:CGRectMake(76, 436,40, 40)\];
\[btn3 setFrame:CGRectMake(140, 436,40, 40)\];
\[btn4 setFrame:CGRectMake(200, 436,40, 40)\];
\[btn5 setFrame:CGRectMake(260, 436,40, 40)\];
// this is iphone 4 xib
}
}![enter image description here][3]
【问题讨论】:
-
为什么自己搞砸了多设备屏幕的代码
-
我没有使用自动布局和故事板这就是我面临这个问题的原因
-
放上你的屏幕截图
-
@iDev 我放截图请看。
-
请勿编辑发布问题图片的答案帖子
标签: ios iphone objective-c ios7 uinavigationbar