mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-04-10 12:05:50 +00:00
add a cheesy button to hide the keyboard
This commit is contained in:
parent
b0da683d1f
commit
a84bd41d58
1 changed files with 24 additions and 0 deletions
|
|
@ -166,6 +166,8 @@
|
|||
[super viewWillAppear:animated];
|
||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
[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]) {
|
||||
[self configureLinkView];
|
||||
}
|
||||
|
|
@ -175,6 +177,8 @@
|
|||
[super viewWillDisappear:animated];
|
||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
[notificationCenter removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
|
||||
[notificationCenter removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
||||
[notificationCenter removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
[self savePost];
|
||||
}
|
||||
|
||||
|
|
@ -193,8 +197,28 @@
|
|||
- (void)applicationWillResignActive:(NSNotification *)note {
|
||||
[self savePost];
|
||||
}
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)note {
|
||||
[self showHideKeyboardButton];
|
||||
}
|
||||
|
||||
- (void)keyboardWillHide:(NSNotification *)note {
|
||||
[self hideHideKeyboardButton];
|
||||
}
|
||||
|
||||
#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;
|
||||
{
|
||||
return self.modifiedPost.new || ![self.modifiedPost isEqualToPost:self.post];
|
||||
|
|
|
|||
Loading…
Reference in a new issue