Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-05-2009, 08:06 AM   #1 (permalink)
turbolag
New Member
 
Join Date: Jul 2008
Posts: 32
turbolag is on a distinguished road
Default UIToolbar lost in rotation to landscape

I am writing an app with navigationBar, tableView, and toolBar programatically. I want the app to work in landscape and portrait mode. Below is my loadView method:

Code:
	//Add the table view			//initWithFrame:CGRectMake(0.0f, 44.0f, 320.0f, 436.0f) ];
	UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
	tableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
	tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
	tableView.delegate = self;
	tableView.dataSource = self;
	
	self.view = tableView;
	//[self.navigationController.view addSubview:tableView];
	
	[tableView release];
	
	//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];
	
	//Add the toolbar as a subview to the navigation controller.
	[self.navigationController.view addSubview:toolbar];
The problems are twofold:
1. The toolbar is pushed off the screen when in landscape mode
2. The toolbar covers the last row of the tableview in portrait

If I hardcode the frame of the tableview, it does not rotate properly. If I add the tableview as a subview to the navigationController.view, I see two tableviews overlaid in landscape mode.

How can I get both the tableview and toolbar to rotate and scale properly? Thanks in advance.
turbolag is offline   Reply With Quote
 

» Advertisements
» Online Users: 453
17 members and 436 guests
apatsufas, brainspoon, buenasuerte, CMSLdesign, Dimpleppanchal, dre, Evilelement, Gaz, ilmman, iphonedevshani, Kieren Harrold, LegionMD, MAMN84, monu_rastogi, QuantumDoja, Robiwan, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,614
Threads: 94,086
Posts: 402,793
Top Poster: BrianSlick (7,990)
Welcome to our newest member, kurtroom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:49 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.