When I click on Text Field, the keyboard pops up hiding it on the screen, I would like to know a way to make Text Field go up along with the keyboard, I tried to use a Scroll View but I could not.
Create the delegate for the textfields and IBOutlet for the scroll and use the following code:
SWIFT:
func textFieldDidBeginEditing(textField : UITextField)
{
var pt : CGPoint
var rc = textField.bounds
rc = textField.convertRect(rc, toView: self.scroll)
pt = rc.origin;
pt.x = 0;
pt.y -= 157; // Ajuste de acordo com a necessidade
self.scroll.setContentOffset(pt, animated: true)
}
OBJECTIVE-C
- (void)textViewDidBeginEditing:(UITextField *)textField
{
CGPoint pt;
CGRect rc = [textField bounds];
rc = [textField convertRect:rc toView:self.scroll];
pt = rc.origin;
pt.x = 0;
pt.y -= 157; // Ajuste de acordo com a necessidade
[self.scroll setContentOffset:pt animated:YES];
}
You can use the TPKeyboardAvoiding
lib ( link ).
Just change the class from UIScrollView
to TPKeyboardAvoidingScrollView
.