summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/NewPostViewController.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-10-15 23:47:11 +0300
committerGravatar Vitaly Takmazov2017-10-15 23:47:11 +0300
commit8ae952ec8df2a713afeaef5960a88888e050c6fc (patch)
treeb7b09deed573336e5d274eed790c30ba57e4a910 /Juick/ViewControllers/NewPostViewController.m
parent6499148cb3f62e20534b62c181125ebeacfa3438 (diff)
WIP
Diffstat (limited to 'Juick/ViewControllers/NewPostViewController.m')
-rw-r--r--Juick/ViewControllers/NewPostViewController.m21
1 files changed, 19 insertions, 2 deletions
diff --git a/Juick/ViewControllers/NewPostViewController.m b/Juick/ViewControllers/NewPostViewController.m
index 318de4e..9643b78 100644
--- a/Juick/ViewControllers/NewPostViewController.m
+++ b/Juick/ViewControllers/NewPostViewController.m
@@ -12,6 +12,7 @@
@interface NewPostViewController ()
@property (nonatomic, assign) BOOL didSetupConstraints;
+@property (nonatomic, assign) int paddingValue;
@end
@@ -21,14 +22,17 @@
{
[super viewDidLoad];
self.navigationController.visibleViewController.title = @"Post";
- self.view.backgroundColor = [ColorScheme mainBackground];
self.navigationController.visibleViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self action:@selector(cancelCompose)];
self.navigationController.visibleViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
- target:self action:@selector(doneCompose)];
+ target:self action:@selector(doneCompose)];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
+ [self.textView becomeFirstResponder];
}
- (void) cancelCompose {
+ [self.textView resignFirstResponder];
[self.navigationController.visibleViewController.navigationController popViewControllerAnimated:YES];
}
@@ -36,4 +40,17 @@
[self.navigationController.visibleViewController.navigationController popToRootViewControllerAnimated:YES];
}
+-(void) keyboardDidShow:(NSNotification *)sender {
+ CGRect frame = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
+ CGRect newFrame = [self.view convertRect:frame fromView:[[UIApplication sharedApplication] delegate].window];
+ [self.view layoutIfNeeded];
+ [UIView animateWithDuration:[sender.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
+ self.bottomConstraint.constant = newFrame.origin.y - CGRectGetHeight(self.view.frame) + self.paddingValue;
+ [self.view layoutIfNeeded];
+ }];
+}
+-(void) keyboardWillHide:(NSNotification *)sender {
+ self.bottomConstraint.constant = self.paddingValue;
+ [self.view layoutIfNeeded];
+}
@end