已弃用的错误
我有以下代码有一个我想删除的问题:
NSDictionary* info = [notif userInfo];
NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;
在代码的第二行,我收到消息“UIKeyboardBoundsUserInfoKey 已弃用”。 我在论坛上读过类似的错误消息并尝试了一些方法,但我的新手思维无法修复它。
Possible Duplicate:
UIKeyboardBoundsUserInfoKey is deprecated, what to use instead?
I have the following code with an issue which I would love to remove:
NSDictionary* info = [notif userInfo];
NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;
On the second line of the code I get the message "UIKeyboardBoundsUserInfoKey is deprecated".
I,ve read similar error messages on the forum and tried a few things but my newby mind can not fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当某些东西被标记为已弃用时,您应该查看文档。您通常会找到有关替换已弃用项目的信息。在本例中,UIWindow 参考的键盘通知用户信息键部分:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html
使用 UIKeyboardFrameBeginUserInfoKey 和 UIKeyboardFrameEndUserInfoKey 而不是 UIKeyboardBoundsUserInfoKey
You should check out the docs anytime something is marked as deprecated. You will usually find info about what has replaced the deprecated item. In this case, the Keyboard Notification User Info Keys section of the UIWindow reference:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html
Use UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey instead of UIKeyboardBoundsUserInfoKey
这意味着不要使用 UIKeyBoundsUserInfoKey。因为它在新的 iOS xcode 中不再存在...所以尝试使用后来的或不同的密钥..ie 看看这个教程
http: //www.w3bookmarks.com/mobile-application-development-tutorial/iphone-questions-uikeyboardboundsuserinfokey-is-deprecated-what-to-use-instead/
it means that DONT USE UIKeyBoundsUserInfoKey. because it is not present anymore in the new iOS xcode... so try to use the later or different key..i.e look at this tutorial
http://www.w3bookmarks.com/mobile-application-development-tutorial/iphone-questions-uikeyboardboundsuserinfokey-is-deprecated-what-to-use-instead/
您可以使用
UIKeyboardFrameEndUserInfoKey
代替UIKeyboardBoundsUserInfoKey
。You can use
UIKeyboardFrameEndUserInfoKey
instead ofUIKeyboardBoundsUserInfoKey
.