0

在我的 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. 应自动旋转到界面方向。

if(UIInterfaceOrientationIsPortrait(interfaeorientation))
{

[self.tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"footerportrait.png"]];

}
else 
{

[self.tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"footerlandscape.png"]];

}

我不知道为什么会这样。

感谢您的帮助。

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

4

1 回答 1

1

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

于 2012-07-19T11:24:20.680 回答