Skip to content

Instantly share code, notes, and snippets.

@arturlector
Last active February 4, 2016 12:44
Show Gist options
  • Save arturlector/66e66380cda8b03f73b5 to your computer and use it in GitHub Desktop.
Save arturlector/66e66380cda8b03f73b5 to your computer and use it in GitHub Desktop.
Keyboard Observer

Как внутри контроллера отслеживать размеры keyboard - чтобы подстраивать tableview.

- (void) addKeyboardObserver {
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; //nil - означает что observer-им всех
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardHidden:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)keyboardWillShow:(NSNotification*)notification {
    DLog(@"%@", [notification userInfo]);
}

- (void)keyboardDidShow:(NSNotification*)notification {
    DLog(@"%@", [notification userInfo]);
}

- (void)keyboardHidden:(NSNotification*)notification {
    DLog(@"%@", [notification userInfo]);
}
2016-02-04 14:54:28.684 PartyPlace[9684:3474492] -[IGSProfileAboutCell keyboardWillShow:](0x138c0dd00) {
    UIKeyboardAnimationCurveUserInfoKey = 7;
    UIKeyboardAnimationDurationUserInfoKey = 0;
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 253}}";
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 456}";
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 441.5}";
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 344}, {320, 224}}";
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 315}, {320, 253}}";
    UIKeyboardIsLocalUserInfoKey = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment