Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-22-2009, 01:05 PM   #3 (permalink)
slybitz
New Member
 
Join Date: Jun 2009
Posts: 10
Default

Quote:
Originally Posted by jsd View Post
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];
slybitz is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,994
Threads: 38,776
Posts: 170,152
Top Poster: smasher (2,560)
Welcome to our newest member, wionj
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.