Created
February 4, 2014 04:05
-
-
Save SehoNoh/8797975 to your computer and use it in GitHub Desktop.
This file contains 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 characters
#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 |
This file contains 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 characters
#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