UINavigationItem titleView “ignored if leftBarButtonItem is set”?

前端 未结 5 568
情话喂你
情话喂你 2020-12-10 14:09

The documentation for UINavigationItem\'s titleView property says:

\"This property is ignored if leftBarButtonItem is not ni

相关标签:
5条回答
  • 2020-12-10 14:38

    I just ran into this and found the same thing you did. I also noted that the documentation for UINavigationItem was last updated in 2011, while UINavigationBar got updates in both iOS 5 and 6, so it's possible this behavior changed since the last time the UINavigationItem doc was updated.

    Very confusing though.

    Noticed this as well in UINavigationController's reference:

    "The navigation controller updates the middle of the navigation bar as follows:

    ...

    If the new top-level view controller has a custom title view, the navigation bar displays that view in place of the default title view. To specify a custom title view, set the titleView property of the view controller’s navigation item."

    Since there's a leftBarByButton (the back button) by definition anytime you're at the non-root view, it sure seems like a mistake in the UINavigationItem's documentation

    0 讨论(0)
  • 2020-12-10 14:48

    Check the documentation for property leftBarButtonItems, it says:

    If there is not enough room to display all of the items in the array, those that would overlap the title view (if present) or the buttons on the right side of the bar are not displayed.

    So, what's said for titleView is probably incorrect.

    0 讨论(0)
  • 2020-12-10 14:49

    I think the documentation is wrong, and you should file a bug report.

    0 讨论(0)
  • 2020-12-10 14:59

    I tested this on iOS6.1 and iOS7. My UINavigationItem had a non-nil titleView and leftBarButtonItem, and both the titleView and leftBarButtonItem were visible. I filed a radar.

    0 讨论(0)
  • 2020-12-10 15:04

    I've run into this as well. In My specific problem both the titleview and leftbar item would appear. However If I had a Back Button then my titleview would disappear on Push and use the default title. If I have a custom uibuttonitem set for the left it works fine. So It seems to be related to back button. I ended up solving by setting title attributes and no doing a custom view.

    0 讨论(0)
提交回复
热议问题