【问题标题】:UIBarButtonItem with portrait and landscape images may show portrait image for landscape orientation带有纵向和横向图像的 UIBarButtonItem 可能会显示横向的纵向图像
【发布时间】:2014-02-07 12:13:12
【问题描述】:

在 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 的视图首先以横向显示(例如,通过以横向显示或通过关闭以横向覆盖它的视图控制器),则使用 portrait 图像反而!为什么会这样?这是一个框架错误吗?如果是这样,有没有办法解决这个问题,所以横向图像将始终以横向显示?

【问题讨论】:

  • 你是在 ipad 上测试吗?

标签: ios7 uinavigationcontroller uinavigationbar uibarbuttonitem landscape


【解决方案1】:

我也遇到了同样的问题。

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

横向图像始终在 UIToolbar 上有效,但在 UINavigationBar 上无效。使用 UINavigationBar,我得到了你所说的问题。我还有一个问题,如果我在横向点击按钮,它会变成纵向版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多