Skip to content

Instantly share code, notes, and snippets.

@choco0908
Last active May 24, 2021 03:45
Show Gist options
  • Save choco0908/0d89b52d53eb31c4e1bb94eac6971ad0 to your computer and use it in GitHub Desktop.
Save choco0908/0d89b52d53eb31c4e1bb94eac6971ad0 to your computer and use it in GitHub Desktop.
Is UIKeyboard Loaded
@property BOOL isKeyboardLoaded;
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillChange:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
}
- (void)keyboardWillChange:(NSNotification *)notification {
//https://stackoverflow.com/questions/22549911/why-is-uikeyboardwillshownotification-called-every-time-another-textfield-is-sel
//키보드 이벤트 발생할때 키보드 프레임변화가 있는지 or 키보드가 떠있는지 확인
CGRect beginFrame = [[notification.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endFrame = [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
if(CGRectEqualToRect(beginFrame, endFrame) == YES) {
logD(@"keyboardFrame isn't changing");
_isKeyboardLoaded = NO;
return;
}
_isKeyboardLoaded = YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment