Created
July 5, 2012 09:50
-
-
Save anderssvendal/3052679 to your computer and use it in GitHub Desktop.
Revisions
-
anderssvendal revised this gist
Jul 5, 2012 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,17 @@ - (void)adjustViewForTextField:(UITextField*)textField animated:(BOOL)animated { self.view.frame = frame; } } } - (void)resetViewAfterEditingAnimated:(BOOL)animated { CGRect frame = self.view.frame; frame.origin.y = 0.0; if (animated) { [UIView animateWithDuration:0.25 animations:^ { self.view.frame = frame; }]; } else { self.view.frame = frame; } } -
anderssvendal created this gist
Jul 5, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ - (void)adjustViewForTextField:(UITextField*)textField animated:(BOOL)animated { CGRect frame = self.view.frame; double screenSize = 480.0; double topHeight = 20.0; double keyboardSize = 216.0; double keyboardPos = screenSize - keyboardSize; double textFieldPos = topHeight + textField.frame.origin.y; double textFieldHeight = textField.frame.size.height; double textFieldBottom = textFieldPos + textFieldHeight; if ((textFieldBottom + frame.origin.y) >= keyboardPos) { frame.origin.y = (keyboardPos - textFieldPos) - textFieldHeight - 10.0; if (animated) { [UIView animateWithDuration:0.25 animations:^ { self.view.frame = frame; }]; } else { self.view.frame = frame; } } }