superuser
superuser

Reputation: 455

UIKeyboardBoundsUserInfoKey is deprecated

How to remove these warnings:

UIKeyboardCenterBeginUserInfoKey is deprecated

UIKeyboardCenterEndUserInfoKey is deprecated

UIKeyboardBoundsUserInfoKey is deprecated

I am getting above warnings in these statements:

CGPoint beginCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterBeginUserInfoKey] CGPointValue];

CGPoint endCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterEndUserInfoKey] CGPointValue];

CGRect keyboardBounds = [[[notification userInfo] valueForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];

Upvotes: 1

Views: 3551

Answers (4)

Anand Mishra
Anand Mishra

Reputation: 1103

UIkeyboardboundsuserinfokey is not working porper in IOS 6 ..

use the UIKeyboardFrameBeginUserInfoKey or UIKeyboardFrameEndUserInfoKey key instead of uikeyboardboundsuserinfokey

Upvotes: 5

Chi-Wei Shih
Chi-Wei Shih

Reputation: 333

Just change this

CGPoint beginCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterBeginUserInfoKey] CGPointValue];

CGPoint endCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterEndUserInfoKey] CGPointValue];

CGRect keyboardBounds = [[[notification userInfo] valueForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];

to this

CGPoint beginCentre = [[[notification userInfo] valueForKey:@"UIKeyboardCenterBeginUserInfoKey"] CGPointValue];

CGPoint endCentre = [[[notification userInfo] valueForKey:@"UIKeyboardCenterEndUserInfoKey"] CGPointValue];

CGRect keyboardBounds = [[[notification userInfo] valueForKey:@"UIKeyboardBoundsUserInfoKey"] CGRectValue];

see the difference?

 @"UIKeyboardBoundsUserInfoKey"

it works fine to me

Upvotes: 3

Nick Bull
Nick Bull

Reputation: 4286

Anything that is marked as deprecated means that it can (and most likely will) be removed in any future versions of the SDK. If you ignore the warnings, then your code will most likely not work in the future when newer versions of the SDK are released.

If you get a warning about this, check the documentation (as jtbandes suggested) and this will give you information about what to use instead.

Upvotes: 1

jtbandes
jtbandes

Reputation: 118761

Simple: just don't use those keys.

If you actually read the documentation, it will tell you you should use UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey.

Upvotes: 4

Related Questions