2012-07-19 33 views
0

在我的iPad应用程序,标签栏控制器 - 标签栏无法设置背景图片纵向首次

我使用的是iOS 5.0。

我已经设置了tabbar的背景图片。

我的应用程序有一个标签栏控制器和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"]]; 

} 

我不知道这是为什么happeninng。

感谢您的帮助。

我认为问题不是图像,但我的导航栏的宽度可能是1024.!

回答

1

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

+0

谢谢MArtin,谢谢你的工作很好。 – 2012-07-19 11:33:48