Skip to content

Instantly share code, notes, and snippets.

@DonMag
Last active February 19, 2018 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DonMag/ea986e5b37225ac9a84d5fbb147f199d to your computer and use it in GitHub Desktop.
Save DonMag/ea986e5b37225ac9a84d5fbb147f199d to your computer and use it in GitHub Desktop.
//
// FirstTabKBViewController.m
// OCVeryTemp
//
// Created by Don Mag on 2/19/18.
//
#import "FirstTabKBViewController.h"
@interface FirstTabKBViewController ()
@end
@implementation FirstTabKBViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Listen for keyboard appearances and disappearances
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification
object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
NSLog(@"FIRST view will dis");
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardDidHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardDidShowNotification
object:nil];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[[self view] endEditing:TRUE];
}
- (void)keyboardDidShow: (NSNotification *) notif{
// Do something here
NSLog(@"FIRST kb did show");
}
- (void)keyboardDidHide: (NSNotification *) notif{
// Do something here
NSLog(@"FIRST kb did hide");
}
@end
//
// SecondTabKBViewController.m
// OCVeryTemp
//
// Created by Don Mag on 2/19/18.
//
#import "SecondTabKBViewController.h"
@interface SecondTabKBViewController ()
@end
@implementation SecondTabKBViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Listen for keyboard appearances and disappearances
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification
object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
NSLog(@"SECOND view will dis");
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardDidHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardDidShowNotification
object:nil];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[[self view] endEditing:TRUE];
}
- (void)keyboardDidShow: (NSNotification *) notif{
// Do something here
NSLog(@"SECOND kb did show");
}
- (void)keyboardDidHide: (NSNotification *) notif{
// Do something here
NSLog(@"SECOND kb did hide");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment