diff options
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r-- | Juick/ViewControllers/ChatViewController.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/ChatViewController.m | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Juick/ViewControllers/ChatViewController.h b/Juick/ViewControllers/ChatViewController.h index f21eb10..f23ecc8 100644 --- a/Juick/ViewControllers/ChatViewController.h +++ b/Juick/ViewControllers/ChatViewController.h @@ -14,6 +14,7 @@ @property(nonatomic, strong) NSMutableArray *messages; @property(nonatomic, strong) NSString *uname; @property (weak, nonatomic) IBOutlet UIStackView *stack; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *stackBottomConstraint; @property (strong, nonatomic) IBOutlet UITableView *tableView; -(void) reloadChat; diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m index 9493155..cfecc48 100644 --- a/Juick/ViewControllers/ChatViewController.m +++ b/Juick/ViewControllers/ChatViewController.m @@ -11,6 +11,8 @@ #import "MessageInputView.h" +#define kMessageInputInitialHeight 50 + @interface ChatViewController () @property (nonatomic, readwrite, retain) MessageInputView *accessoryView; @@ -37,6 +39,8 @@ [self addObserver:self forKeyPath:@"uname" options:0 context:nil]; #if TARGET_OS_MACCATALYST [self.stack addArrangedSubview:[self inputAccessoryView]]; +#else + self.stackBottomConstraint.constant = kMessageInputInitialHeight; #endif } @@ -102,11 +106,12 @@ if (userInfo) { CGRect beginFrame = [userInfo [UIKeyboardFrameBeginUserInfoKey] CGRectValue]; CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; - CGFloat delta = endFrame.origin.y - beginFrame.origin.y; + CGFloat keyboardHeight = endFrame.origin.y - beginFrame.origin.y; CGFloat duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue]; UIViewAnimationCurve animationCurve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue]; + [UIView animateWithDuration:duration delay:0 options:(animationCurve << 16) animations:^{ - self.tableView.contentOffset = CGPointMake(0, self.tableView.contentOffset.y - delta); + self.tableView.contentOffset = CGPointMake(0, self.tableView.contentOffset.y - keyboardHeight); } completion:nil]; } } |