rob-brown / RBStoryboardLink

Makes transitioning between storyboards possible.
Other
841 stars 110 forks source link

Navigation bar title when using TabBar #44

Open tomekc opened 9 years ago

tomekc commented 9 years ago

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!

BottleMan commented 9 years ago

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

andres-cianio commented 9 years ago

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:

fatuhoku commented 9 years ago

:+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.

mokagio commented 9 years ago

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

@rob-brown any thoughts on the matter?

stanislaw commented 9 years ago

+1

MichaelPei commented 9 years ago

@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.

MarcosEich commented 9 years ago

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