Quote:
Originally Posted by jsd
You added the toolbar to the navigation view so of course it's going to show on all navigation controller owned views from then on. Add it to view2's view instead and you should be good to go.
|
Thanks JSD. I changed it to: [self.view addSubview:toolbar]; which works but I still have an issue... How do I set the location of the toolbar to be static like it was when it was on the navigation controller where it is always visible and static at the bottom of the screen/view even if the view2's height is larger than what is on the screen? Right now, my toolbar is located way down past the end of the screen and I have to scroll down to see it. I can change the rootViewHeight to move it but then as the user scrolls on the tableview the toolbar also moves.
Code:
//Initialize the toolbar
toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleDefault;
//Set the toolbar to fit the width of the app.
[toolbar sizeToFit];
//Caclulate the height of the toolbar
CGFloat toolbarHeight = [toolbar frame].size.height;
//Get the bounds of the parent view
CGRect rootViewBounds = self.parentViewController.view.bounds;
//Get the height of the parent view.
CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);
//Get the width of the parent view,
CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);
//Create a rectangle for the toolbar
CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);
//Reposition and resize the receiver
[toolbar setFrame:rectArea];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
UIBarButtonItem* bi = [[UIBarButtonItem alloc]
initWithTitle:@"Submit" style:UIBarButtonItemStyleBordered target:self action:@selector(sign_clicked:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
// stick the buttons in the toolbar
[toolbar setItems:buttons animated:NO];
[buttons release];
//Add the toolbar as a subview to the navigation controller.
[self.view addSubview:toolbar];
//Reload the table view
[self.tableView reloadData];
[toolbar release];