views:

186

answers:

2

I think I'm missing something obvious and would appreciate an answer.

I have a view with a 2-section grouped tableView, each section having one row and a textView, the heights of the rows 335 and 140. This allows for a box with nicely rounded corners to type text into when the keyboard appears (140 height section) and when the keyboard is dismissed, a nice box to read more text (notes); most of the time, use is without the keyboard.

I also added a toolbar at the bottom of the screen to scroll up above the keyboard. A button on the toolbar dismisses the keyboard. This last part works fine with the keyboard going up and down using a notification and the following code in a keyboardWillShow method:

[UIView beginAnimations:@"showKeyboardAnimation" context:nil];
[UIView setAnimationDuration:0.50];
self.view.frame = CGRectMake(self.view.frame.origin.x,
                             self.view.frame.origin.y,
                             self.view.frame.size.width,
                             self.view.frame.size.height - 216);
[UIView commitAnimations];

But with the above code, the 2 sections of the tableView remain unscrolled, only the toolbar and the keyboard move. With the following code (found both in previous posts), both the toolbar and the tableView sections move.

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.50];

CGRect rect = self.view.frame;
rect.origin.y -= 216; 
self.view.frame = rect;

[UIView commitAnimations];

Now I know that I have to tweak the numbers to get the everything as I want it but my first question is what is substantively different between the 2 sets of code that the sections move in the 2nd but not in the 1st? The toolbar also moves with the 2nd code.

The second question is, am I going to be able to scroll the smaller height section from off the screen to above the keyboard while at the same time moving the toolbar up just 216?

Thanks

+1  A: 

I may be missing something here, but in the first piece of code, you are changing the height by 216. While on the 2nd piece of code, you are changing the origin of the entire view by 216 in the y-direction.

Depending on how you have the frame set in IB, the first piece of code might not move it if you don't allow it to move in that direction. Check your settings in the inspector window.

When you are saying "unscrolled" you are referring to them not changing location within the main view correct? This would be different than them actually scrolling (which you can do as well by changing scroll value).

You may want to check out the Hidden Drawer example here, since they push views in and out of the main view, sort of like a toolbar, and I think that is what you are asking. The whole "scrolling" thing is throwing me off though.

http://cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html

iWasRobbed
Thank you, Rob. I was staring at that for the longest (height vs. origin) and didn't see it. The link is perfect to get me to do what I want.
Matt Winters
Never hurts to get a second pair of eyes on a problem! Good luck, glad to help.
iWasRobbed
A: 

From memory, something like

tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
tc.