带有纵向和横向图像的UIBarButtonItem可能会显示横向方向的纵向图像

时间:2014-01-17 23:59:24

标签: ios7 uinavigationcontroller uinavigationbar uibarbuttonitem landscape

在iOS 7中,我在UINavigationController的导航栏中显示了一个UIBarButtonItem。 UIBarButtonItem具有纵向方向的图像和横向方向的另一个图像:

// "self" refers to the UINavigationController
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:portraitImage landscapeImagePhone:landscapeImage style:UIBarButtonItemStylePlain target:nil action:NULL];

如果只是旋转界面,则正确的图像用于界面方向。但是,如果UINavigationController的视图首先以横向显示(例如,通过横向显示或通过关闭以横向方向覆盖它的视图控制器),则使用纵向图像代替!为什么会这样?这是一个框架错误吗?如果是这样,有没有办法解决这个问题,那么横向图像将始终显示为横向?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。

我在UIBarButtonItem with separate portrait and landscape images - layoutSubviews not called when popping a view controller from UINavigationController找到了一个听起来很有希望的解决方案,但它对我不起作用。我打算改变方向改变的图像。如果您找到更好的东西,请发布您的解决方案。

横向图像一直在UIToolbar上运行,但不是UINavigationBar。使用UINavigationBar,我得到你说的问题。我也有一个问题,如果我在横向上点击按钮,它将改为纵向版本。