I have 8 text fields in the table view. I need to enter the data into that text fields in both Portrait and Landscape mode. some text fields are back side of the Key board.I am unable to enter data into that text fields.
I have done in portrait mode with help of willShowKeyBoard notification and working fine.But, Same thing i have applied to Landscape mode but it doesn't working fine. How to move the table view upwards to enter the data in the text fields?
(void)keyboardWillShow:(NSNotification *)notif {
if ([NameField isFirstResponder] && myView.frame.origin.y >= 0) { } else if([credentialField isFirstResponder] && myView.frame.origin.y >=0) { } else if([specialityField isFirstResponder] && myView.frame.origin.y >=0) { } else if([streetField isFirstResponder] && myView.frame.origin.y >=0) { [self setViewMovedUp:YES]; } else if([cityField isFirstResponder] && myView.frame.origin.y >=0) { [self setViewMovedUp:YES]; } else if([stateField isFirstResponder] && myView.frame.origin.y >=0) { [self setViewMovedUp:YES]; } else if([zipcodeField isFirstResponder] && myView.frame.origin.y >=0) { [self setViewMovedUp:YES]; }
}
-(void)setViewMovedUp:(BOOL)movedUp
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5]; // if you want to slide up the view
CGRect rect = myView.frame;
if (movedUp)
{
rect.origin.y = rect.origin.y - kOFFSET_FOR_KEYBOARD1;
rect.size.height = rect.size.height + kOFFSET_FOR_KEYBOARD1;
}
else
{
rect.origin.y = rect.origin.y + kOFFSET_FOR_KEYBOARD1;
rect.size.height = rect.size.height - kOFFSET_FOR_KEYBOARD1;
}
myView.frame=rect;
[UIView commitAnimations];
}