Skip to content

Instantly share code, notes, and snippets.

@SehoNoh
Created February 4, 2014 04:05
Show Gist options
  • Save SehoNoh/8797975 to your computer and use it in GitHub Desktop.
Save SehoNoh/8797975 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
@interface UITextFieldKeyboardIssues : UIViewController <UITextFieldDelegate>
{
CGRect screenRect;
CGFloat X;
CGFloat Y;
CGFloat WIDTH;
CGFloat HEIGHT;
}
@property (weak, nonatomic) IBOutlet UITextField *textField;
@end
#import "UITextFieldKeyboardIssues.h"
@interface UITextFieldKeyboardIssues ()
@end
@implementation UITextFieldKeyboardIssues
- (void)viewDidLoad
{
[super viewDidLoad];
self.textField.delegate = self;
screenRect = [[UIScreen mainScreen] bounds];
WIDTH = screenRect.size.width;
HEIGHT = screenRect.size.height;
X = 0;
if(HEIGHT == 460)
Y = -180;
else
Y = -210;
}
- (void) textFieldDidBeginEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(X, Y, WIDTH, HEIGHT);
[UIView commitAnimations];
}
- (void) textFieldDidEndEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(X, 0, WIDTH, HEIGHT);
[UIView commitAnimations];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment