0

I have a Navigation Controller with two Views. The First View is a ViewController with a TableView and the Second View is UIView with some UILabels and a UIWebView. When selecting a cell from the TableView, the Navigation Controller pushes to the Second View.

I've added a UIToolBar to Navigation Controller and some buttons.

My problem is when the Navigation Controller pushes to the Second View (UIView), my UIToolBar appears but without the buttons.

I would like to either show different buttons or remove the UIToolBar from the Second View. I think I need to do something within the AppDelegate, I'm just not sure what and how.

Here is how my XIBS look:

MainWindow
- App Delegate
- Window
- Navigation Controller
-- Navigation Bar
-- ToolBar
-- View Controller 
--- Bar Button Item
--- Navigation Item 
---- Bar Back Item

ViewController
-TableView

DetailView
-View
--Web View
--Label
--Label

Code:

AppDelgate.h

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
 UIWindow *window;
 UINavigationController *navigationController;
 UIToolbar *toolBar;  
}

@property (nonatomic, strong) IBOutlet UIWindow *window;
@property (nonatomic, strong) IBOutlet UINavigationController *navigationController;
@property (nonatomic, strong) IBOutlet UIToolbar *toolBar;

@end

AppDelegate.m

@implementation AppDelegate

@synthesize window;
@synthesize navigationController;
@synthesize toolBar;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

// Override point for customization after app launch    

[window addSubview:[navigationController view]];

[window makeKeyAndVisible];

}

- (void)applicationWillTerminate:(UIApplication *)application {
// Save data if appropriate
}

@end

Any help would be appreciated. Thanks

Nick Rivers
  • 294
  • 1
  • 6
  • 17

2 Answers2

2

You have to specify the toolBarItems for each View you load onto the stack. So,

-(void)viewDidLoad{
    [self setToolbarItems:myArrayOfItems];
    //do this in every view controller
    //other code.
}
CodaFi
  • 43,043
  • 8
  • 107
  • 153
0

I cant get you clearly. i suggest this with the assumption. If you want add button in the top bar of the nextview means, you dont use toolbar for that. You can add button in the navigation bar itself. you can add the button using addsubview method. Initialize UIbutton using initwithframe. then add that as a subview of navigation controller. [navigationcont addsubview:button];

SARANGA
  • 172
  • 1
  • 8