From 677397be225a3b34f4b26e573fd067f73f9eb75c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 1 Apr 2018 22:21:20 +0300 Subject: Fix login --- Juick/ViewControllers/LoginViewController.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Juick/ViewControllers/LoginViewController.m') diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m index 4f63e44..fd3c2b0 100644 --- a/Juick/ViewControllers/LoginViewController.m +++ b/Juick/ViewControllers/LoginViewController.m @@ -12,6 +12,10 @@ #import "AppDelegate.h" #import "APIClient.h" +@interface LoginViewController() +@property (nonatomic, assign) int paddingValue; +@end + @implementation LoginViewController - (void) awakeFromNib { @@ -26,6 +30,18 @@ target:self action:@selector(doneSignIn)]; self.usernameField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"]; self.passwordField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; +} + +-(void) keyboardDidShow:(NSNotification *)sender { + CGRect keyboardRect = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; + self.bottomConstraint.constant = keyboardRect.size.height - self.view.safeAreaInsets.bottom + self.paddingValue; + [self.view layoutIfNeeded]; +} +-(void) keyboardWillHide:(NSNotification *)sender { + self.bottomConstraint.constant = self.paddingValue; + [self.view layoutIfNeeded]; } -- cgit v1.2.3