RBStoryboardLink icon indicating copy to clipboard operation
RBStoryboardLink copied to clipboard

Navigation bar title when using TabBar

Open tomekc opened this issue 10 years ago • 8 comments

I have TabBar application and one of the tabs is starting with NavigationController.

The problem is that I am unable to set navigation bar title, in either way:

self.navigationItem.title = "nav item title"

Title remains unchanged. It will work if I move navigation controller to separate storyboard, but then navbar is rendering incorrectly (not extending under status bar).

Any clues? Thanks!

tomekc avatar Nov 01 '14 22:11 tomekc

I have sove just the same problem after adding "needsTopLayoutGuide" = NO to User Defined Runtime Attributes.

BottleMan avatar Nov 11 '14 08:11 BottleMan

Neither of the previous options worked for me. I ended up fixing this setting the title of the parentViewController:

[self.parentViewController setTitle:NSLocalizedString(@"MyTitle", nil)];

Like stated before, accessing the parent is quite hacky though :-1:

andres-cianio avatar Jan 30 '15 14:01 andres-cianio

:+1: accessing the parent is unforgivable, really. RBStoryboardLink should be totally transparent.

Part of the problem is that RBStoryboardLink is responsible for creating the view controller it points at and effectively takes a 'snapshot' of its properties. However, whenever we change the view controller's settings these changes cannot be propagated upstream.

RBStoryboardLink should work reactively rather than statically. It should use KVO to observe and expose the navigationItem of the underlying view controller rather than maintain one itself. It has no right to.

fatuhoku avatar Feb 15 '15 11:02 fatuhoku

I just had a similar problem with the rightBarButtonItem, and yeah accessing the parentViewController is not optimal...

@rob-brown any thoughts on the matter?

mokagio avatar Feb 24 '15 18:02 mokagio

+1

stanislaw avatar Feb 26 '15 17:02 stanislaw

@tomekc @stanislaw Actually I think you guys should use the property 'rbsl_storyboardLink', which is defined in the UIViewController+RBStoryboardLink, to access surrogate view controller and change the property you wanted, the code should look like:

self.rbsl_storyboardLink.navigationItem.title = "nav item title";

Because when you change navigation item or others, actually you are changing the navigation item of your container navigation controller's navigation item and now the surrogate view controller (a RBStoryboardLink class) is contained in the navigation controller not your view controller, so you should access property like the code above. Hope this will help.

MichaelPei avatar Feb 27 '15 06:02 MichaelPei

Having the same problem here. It would be nice to have a fix for this.

MarcosEich avatar May 08 '15 21:05 MarcosEich