【问题标题】:Tab Bar controller - Tab bar could not set background image for portrait orientation for first time标签栏控制器 - 标签栏第一次无法为纵向设置背景图像
【发布时间】:2012-07-19 10:01:59
【问题描述】:

在我的 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"]];

}

我不知道为什么会这样。

感谢您的帮助。

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

【问题讨论】:

    标签: objective-c ios xcode cocoa-touch


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-08
      • 1970-01-01
      • 1970-01-01
      • 2012-05-02
      • 2014-06-13
      相关资源
      最近更新 更多