0

I currently have a Main Window set up as a UINavigationController (also is the root view controller), and I have two views. The first view is the login screen, and the second screen is a table view screen. What I would like to have happen is to show different UIBarButtonItems based on what screen is showing up. For instance, when the logon screen is being displayed, I want a left button on the navigation bar to be displayed (more specifically, it'd be a Settings button before logging in). Once the user logs in, I want the left button to say "Logout" and the right to be a reload button. I've tried programmatically adding the buttons, but they won't show up. Any suggestions?

Also, I've gotten most of this done in IB, but I feel like it would probably be easier to add these buttons programmatically.

SpacePyro
  • 3,121
  • 4
  • 25
  • 30

1 Answers1

1

All subclasses of UIViewController have a property called navigationItem. While it is readonly, you can alter its properties. So in LoginViewController, you would do self.navigationItem.leftBarButtonItem = /* Code to create the bar button */ and likewise within the TableViewController. Let me know if you need more detail.

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
  • I see, I think I'll stick with this approach. I did read up on this but it wasn't working out for me. Thanks! – SpacePyro May 20 '11 at 23:56