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];
CG开发者_如何学JAVARect keyboardBounds = [[[notification userInfo] valueForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
UIkeyboardboundsuserinfokey
is not working porper in IOS 6 ..
use the UIKeyboardFrameBeginUserInfoKey
or UIKeyboardFrameEndUserInfoKey
key instead of uikeyboardboundsuserinfokey
Simple: just don't use those keys.
If you actually read the documentation, it will tell you you should use UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey.
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
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.
精彩评论