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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-07-2009, 11:13 AM   #1 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Nov 2009
Posts: 179
thewitt is on a distinguished road
Default setToolbarHidden clips UITableView

I am working on my first iPhone app, though I'm not a beginning programmer by any means I am new to the platform and Objective-C, so I am hitting some interesting bumps along the way.

Here's one that I hope someone has seen and can help me figure out what I'm doing wrong.

I have a Navigation Controller with a UITableView (subview) as my main view. I use both button locations on the Navigation Bar ("Edit" and "+"), so I've added a Toolbar and am displaying an "I" info button on the far right that allows me to show an application information screen.

When I press the "I" button, I animate the replacement of the UITableView with a UIWebView containing the Info screen; remove the "Edit" button; change the "+" button to a "Done" button and animate the removal of the Toolbar (more display room for the info page).

So far, so good.

When I press the "Done" button, I animate the UITableView back in; add the "Edit" button back to the Navigation Bar; replace the "Done" button with the "+" button and animate the Toolbar back with the "I" button in place.

Here's the problem.

The UITableView view region has now been clipped by the height of the Toolbar. Each time I run through this sequence, the view region shrinks again, until ultimately it's gone... I can still scroll through all of the entries in the table as long as I can see just one of them, but the white space below the table eventually grows and eats up the table one "Toolbar height" at a time.

Any ideas what I'm missing here?

All of this happens inside my RootViewController. The UITableView and UIWebView are separate subviews that are defined in the xib file and animated with removeFromSuperview and addSubview.

I remove and bring back the Toolbar changing the hidden attribute for

[self.navigationController setToolbarHidden:TRUE animated:TRUE]

Animating the toolbar in and out makes no difference, just simply hiding and showing it seems to be enough.

If I leave the Toolbar in place and don't remove and add it back, everything is fine, so it's the removal and replacement that's triggering the problem. I hate to leave the Toolbar in place simply because the extra space is nice to have in the information view - and because I hate having problems like this that I can't solve

Thanks,

-t
thewitt is offline   Reply With Quote
Old 11-07-2009, 11:23 AM   #2 (permalink)
Registered Member
 
p machine's Avatar
 
Join Date: Jun 2009
Posts: 18
p machine is on a distinguished road
Default

It sounds like you are hiding the toolbar, then creating a new toolbar when you animate back, so there are more and more toolbars, pushing your tableview down.
p machine is offline   Reply With Quote
Old 11-07-2009, 11:57 AM   #3 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Nov 2009
Posts: 179
thewitt is on a distinguished road
Arrow

Quote:
Originally Posted by p machine View Post
It sounds like you are hiding the toolbar, then creating a new toolbar when you animate back, so there are more and more toolbars, pushing your tableview down.
Certainly sounds like it describes the behavior - though I'm not sure why this would be the case.

The code that toggles views (clubView and InfoView) based on the button press is:

Code:
(animation setup)

if ([self.clubView superview]) {
  [self.clubView removeFromSuperview];
  [self.view addSubview:infoView];
} else {
  [self.infoView removeFromSuperview];
  [self.view addSubview:clubView];
}
	
[UIView commitAnimations];
		
// adjust our done/info/edit buttons accordingly
if ([infoView superview]) {
  // Swap Add and Done, remove Edit, Remove Toolbar
  self.navigationItem.rightBarButtonItem = doneButton;
  [self.navigationItem setLeftBarButtonItem:nil animated:YES]; 
  [self.navigationController setToolbarHidden:TRUE animated:TRUE];
} else {
  // Bring back Add and Edit buttons and the Toolbar
  self.navigationItem.rightBarButtonItem = addButton;
  [self.navigationItem setLeftBarButtonItem:self.editButtonItem animated:YES]; 
  [self.navigationController setToolbarHidden:FALSE animated:TRUE];
}
I don't see where this would cause a new Toolbar to be created.

I'm using the Toolbar from the xib file that's part of the Navigation Controller. What would cause me to be getting a new instance of that Toolbar, when all I think I'm doing is unhiding it?

-t
thewitt is offline   Reply With Quote
Old 11-07-2009, 12:34 PM   #4 (permalink)
Registered Member
 
p machine's Avatar
 
Join Date: Jun 2009
Posts: 18
p machine is on a distinguished road
Default

I think, and I could have this wrong, that you are writing too much code.

Take a look at the UINavigationController Class methods, there is a push and pop method that will do everything you are doing more efficiently.

I believe that when you are manually setting the subview and superviews you are creating new instances of those views. The Nav Controller behind is retaining that old views toolbar even though it is "hidden." When you manually reset the subview and set the toolbar to "unhidden" the nav controller is unhiding that subviews toolbar.

If you use the push and pop methods you will be working with a stack. When you push the infoview on the stack it will cover the toolbar, when you pop it off, it will be visible.
p machine is offline   Reply With Quote
Reply

Bookmarks

Tags
clipping, navigationcontroller, settoolbarhidden, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 342
11 members and 331 guests
alexP, ClerurcifeDer, Duncan C, givensur, glenn_sayers, guusleijsten, JmayLive, NetGuru, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:41 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0