Last active
May 24, 2021 03:45
-
-
Save choco0908/0d89b52d53eb31c4e1bb94eac6971ad0 to your computer and use it in GitHub Desktop.
Is UIKeyboard Loaded
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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