add a cheesy button to hide the keyboard

This commit is contained in:
Sami Samhuri 2015-05-03 16:12:14 -07:00
parent b0da683d1f
commit a84bd41d58

View file

@ -166,6 +166,8 @@
[super viewWillAppear:animated]; [super viewWillAppear:animated];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil]; [notificationCenter addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
[notificationCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[notificationCenter addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
if ([self pasteboardHasLink]) { if ([self pasteboardHasLink]) {
[self configureLinkView]; [self configureLinkView];
} }
@ -175,6 +177,8 @@
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter removeObserver:self name:UIApplicationWillResignActiveNotification object:nil]; [notificationCenter removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
[notificationCenter removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[notificationCenter removeObserver:self name:UIKeyboardWillHideNotification object:nil];
[self savePost]; [self savePost];
} }
@ -193,8 +197,28 @@
- (void)applicationWillResignActive:(NSNotification *)note { - (void)applicationWillResignActive:(NSNotification *)note {
[self savePost]; [self savePost];
} }
- (void)keyboardWillShow:(NSNotification *)note {
[self showHideKeyboardButton];
}
- (void)keyboardWillHide:(NSNotification *)note {
[self hideHideKeyboardButton];
}
#pragma mark - #pragma mark -
- (void)showHideKeyboardButton;
{
UIBarButtonItem *hideKeyboardItem = [[UIBarButtonItem alloc] initWithTitle:@"^^" style:UIBarButtonItemStylePlain target:self.textView action:@selector(resignFirstResponder)];
self.navigationItem.rightBarButtonItem = hideKeyboardItem;
}
- (void)hideHideKeyboardButton;
{
self.navigationItem.rightBarButtonItem = nil;
}
- (BOOL)isDirty; - (BOOL)isDirty;
{ {
return self.modifiedPost.new || ![self.modifiedPost isEqualToPost:self.post]; return self.modifiedPost.new || ![self.modifiedPost isEqualToPost:self.post];