【问题标题】:Deprecated error [duplicate]不推荐使用的错误[重复]
【发布时间】:2012-08-09 21:39:56
【问题描述】:

可能重复:
UIKeyboardBoundsUserInfoKey is deprecated, what to use instead?

我有以下代码,我想删除一个问题:

NSDictionary* info = [notif userInfo];
NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];  
CGSize keyboardSize = [aValue CGRectValue].size;

在代码的第二行,我收到消息“UIKeyboardBoundsUserInfoKey 已弃用”。 我在论坛上阅读过类似的错误消息并尝试了一些方法,但我的新手无法修复它。

【问题讨论】:

标签: objective-c cocoa-touch


【解决方案1】:

您应该在任何时候查看文档标记为已弃用。您通常会找到有关已替换已弃用项目的信息。在这种情况下,UIWindow 参考的键盘通知用户信息键部分:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html

使用 UIKeyboardFrameBeginUserInfoKey 和 UIKeyboardFrameEndUserInfoKey 代替 UIKeyboardBoundsUserInfoKey

【讨论】:

    【解决方案2】:

    这意味着不要使用 UIKeyBoundsUserInfoKey。因为它不再出现在新的 iOS xcode 中......所以尝试使用更高版本或不同的键..即查看本教程 http://www.w3bookmarks.com/mobile-application-development-tutorial/iphone-questions-uikeyboardboundsuserinfokey-is-deprecated-what-to-use-instead/

    【讨论】:

      【解决方案3】:

      您可以使用UIKeyboardFrameEndUserInfoKey 代替UIKeyboardBoundsUserInfoKey

      【讨论】:

        猜你喜欢
        • 2012-07-19
        • 1970-01-01
        • 2012-11-14
        • 2012-08-03
        • 1970-01-01
        • 2015-07-05
        • 1970-01-01
        • 1970-01-01
        • 2014-11-04
        相关资源
        最近更新 更多