选项卡栏控制器-选项卡栏第一次无法设置纵向的背景图像



在我的ipad应用程序中,

我使用的是ios 5.0。

我已经设置了选项卡的背景图像。

我的应用程序有一个选项卡栏控制器,menuVC是视图控制器之一。

我的问题是

当我在人像模式下启动应用程序时,我可以看到横向模式的图像

1.在Appdelegate中

if(menuVC.interfaceOrientation==UIInterfaceOrientationPortrait  ||      menuVC.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
{ 
[tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"footerportrait.png"]];
}
else {
[tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"footerlandscape.png"]];
}

2.In应自动旋转到界面方向

if(UIInterfaceOrientationIsPortrait(interfaeorientation))
{
[self.tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"footerportrait.png"]];
}
else 
{
[self.tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"footerlandscape.png"]];
}

我不知道为什么会发生这种事

谢谢你的帮助。

我认为问题不在于图像,而是我的导航栏的宽度可能是1024。!

根据我的经验,UIViewController的interfaceOrientation属性在AppDelegate中创建时是无效的,只有在调用-viewDidAppear:animated之后。因此,您可以在视图控制器的方法中设置背景图像。

最新更新