Modifying UINavigation Bar Buttons in SubViews

Posted by james on Stack Overflow See other posts from Stack Overflow or by james
Published on 2010-05-30T16:32:23Z Indexed on 2010/05/30 16:42 UTC
Read the original article Hit count: 382

Filed under:
|
|

I'm having trouble trying to modify the navigation bar in the subview portion of my application.

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:UIBarButtonSystemItemDone 
target:self action:@selector(add_Clicked:)] autorelease];

I have no issues modifying the navigation bar in any of my UIViewControllers classes.

The simplified application class outline is as such:

AppDelegate - UIViewControllerA (has a left and a right navigationBarButton) - Subview is displayed when a SegmentControl is selected. (Within the subview, I'm trying to modify the right NavigationBarButton that is displayed)

[self.view addSubview:newControllerName.view];

Methods I have attempted:

  • Trying to set self.navigationItem.rightBarButtonItem within my subview to a new UIBarButtonItem.
  • Creating a pointer to UIViewControllerA within my AppDelegate. The UIViewControllerA contains a function setNavButton I wrote to set the rightBarButtonItem to a button. Then I am referencing the AppDelegate's reference to UIViewControllerA and attempting to call setNavButton. I included a NSLog call to see if that function is being called and it is executing but the NavigationBar isn't being modified.

I'm trying to avoid having to push a UIViewController after the SegmentControl is clicked in UIViewControllerA so that I can simulate the SegmentControl as tabs.

I'm not getting any errors during compile or run time.

Anyone have any ideas?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiview