Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIKeyboardBoundsUserInfoKey Deprecated

I am trying to use the code below however Xcode tells me UIKeyboardBoundsUserInfoKey is deprecated and I was wondering what the newer code was instead:

NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];

And below is the code in context:

-(void) keyboardDidHide: (NSNotification *)notif {


    NSDictionary* info = [notif userInfo];
    NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
    CGSize keyboardSize = [aValue CGRectValue].size;
    CGRect viewFrame = self.view.frame; 
    viewFrame.size.height += keyboardSize.height;
    scrollView.frame = viewFrame;

    if (!keyboardVisible) {
        //NSLog(@"Keyboard is already hidden. Ignoring notification.");
        return;
    }

    keyboardVisible = NO;

}

1 Answers

You can use the UIKeyboardFrameBeginUserInfoKey or UIKeyboardFrameEndUserInfoKey key instead of UIKeyboardBoundsUserInfoKey.

like image 171
Tomasz Wojtkowiak Avatar answered Jan 25 '26 20:01

Tomasz Wojtkowiak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!