The documentation for UINavigationItem's titleView
property says: "This property is ignored if leftBarButtonItem
is not nil."
However, I've set both the titleView
and leftBarButtonItem
properties in my testing and they both appear to show up fine. I've tested on all the simulators in my Xcode: 4.3, 5.0, and 5.1. Does anyone know if the documentation is just wrong, or is it correct on some older versions (e.g. 4.2, 3.x) that I haven't been able to test?
I think the documentation is wrong, and you should file a bug report.
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:
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
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.
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.
Check the documentation for property leftBarButtonItems, it says:
So, what's said for
titleView
is probably incorrect.