diff --git a/src/ios/Base.lproj/Main.storyboard b/src/ios/Base.lproj/Main.storyboard index 987c7229a..f5377f4e4 100644 --- a/src/ios/Base.lproj/Main.storyboard +++ b/src/ios/Base.lproj/Main.storyboard @@ -163,6 +163,7 @@ + diff --git a/src/ios/YassViewController.h b/src/ios/YassViewController.h index 355ca9122..9493afcde 100644 --- a/src/ios/YassViewController.h +++ b/src/ios/YassViewController.h @@ -26,6 +26,7 @@ - (NSString*)getCipher; @property (weak, nonatomic) IBOutlet UILabel *status; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint; @end diff --git a/src/ios/YassViewController.mm b/src/ios/YassViewController.mm index c01ef1083..16a3c645e 100644 --- a/src/ios/YassViewController.mm +++ b/src/ios/YassViewController.mm @@ -72,6 +72,31 @@ - (void)viewWillAppear:(BOOL)animated { YassAppDelegate* appDelegate = (YassAppDelegate*)UIApplication.sharedApplication.delegate; [appDelegate reloadState]; + [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notification) { + NSDictionary *userInfo = notification.userInfo; + NSTimeInterval duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; + CGRect keyboardEndFrame = [self.view.superview convertRect:[userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue] toView:self.view.window]; + + CGRect windowFrame = [self.view.superview convertRect:self.view.window.frame toView:self.view.window]; + CGFloat heightOffset = (windowFrame.size.height - keyboardEndFrame.origin.y) - self.view.superview.frame.origin.y; + + self.bottomConstraint.constant = heightOffset + 20; + + [UIView animateWithDuration:duration + animations:^{ + [self.view layoutIfNeeded]; + }]; + }]; + + [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notification) { + NSDictionary *userInfo = notification.userInfo; + NSTimeInterval duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; + self.bottomConstraint.constant = 20; + [UIView animateWithDuration:duration + animations:^{ + [self.view layoutIfNeeded]; + }]; + }]; [super viewWillAppear:animated]; }