I implemented this function from a stack overflow answer, first answer Move view when so that keyboard does not hide text field ,
//method to move the view up/down whenever the keyboard is shown/dismissed
-(void)setViewMovedUp:(BOOL)movedUp
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3]; // if you want to slide up the view
CGRect rect = self.view.frame;
if (movedUp)
{
// 1. move the view's origin up so that the text field that will be hidden come above the keyboard
// 2. increase the size of the view so that the area behind the keyboard is covered up.
rect.origin.y -= kOFFSET_FOR_KEYBOARD;
rect.size.height += kOFFSET_FOR_KEYBOARD;
}
else
{
// revert back to the normal state.
rect.origin.y += kOFFSET_FOR_KEYBOARD;
rect.size.height -= kOFFSET_FOR_KEYBOARD;
}
self.view.frame = rect;
[UIView commitAnimations];
}
now it works great on ipad. I have a text box and some buttons next to it and above it a textview which has chat. you use the textbox to type your chat. on iphone it moves the textbox you type in and the buttons up, but it doesn't move the textview. in fact it stays covering most of the window and the buttons are moved up on top of around the middle of it.
Now i just created the iphone storyboard view (has one view now) tonight and wiring all my controls to it that work on ipad. now the program works properly still on ipad and even moving the view up on show keyboard works. but on iphone it moves everything but the main console, a UITextView up. Which is to bad the point was to be able to read text while you type :) Also i want to understand the theory here. It seems if i'm defining the view as a rectangle and moving it up some number like 250, it should all move. Maybe there's a better way to do it, like get the keyboard size exactly first, but still i would expect it to move that height.
Mike
I added support for portrait and landscape but the fix was to reset if iPod the main console(the textview) to it's location in portrait(my only iPod orientation) for both up and down after i moved the frame. The whole view was moved so i could set it to the same spot and it would translate in both move up and down.:
double tall = 88;
if(![self isTall])
tall =0;
if (movedUp)
{
// 1. move the view's origin up so that the text field that will be hidden come above the keyboard
// 2. increase the size of the view so that the area behind the keyboard is covered up.
rect.origin.y -= kOFFSET_FOR_KEYBOARD;
rect.size.height += kOFFSET_FOR_KEYBOARD;
self.view.frame = rect;
if ( IDIOM != IPAD )
self._mainConsole.frame = CGRectMake(5, 5, 310, 379 + tall);
}
else
{
// revert back to the normal state.
rect.origin.y += kOFFSET_FOR_KEYBOARD;
rect.size.height -= kOFFSET_FOR_KEYBOARD;
self.view.frame = rect;
if ( IDIOM != IPAD )
self._mainConsole.frame = CGRectMake(5, 5, 310, 379 + tall);
}