objective-c - 自定义键盘中的 iOS 8.3 'UIView-Encapsulated-Layout-Width'

标签 objective-c ios8 autolayout custom-keyboard

我实现了自定义键盘。它在运行 iOS 8.2 的设备上运行良好。

但是,当我在装有 iOS 8.3 的设备上运行相同的代码时,我收到以下警告并且键盘高度设置不正确:

Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x15dd1da0 h=-&- v=-&- Keyboard:0x15db2b00.width == UIView:0x15da7b90.width - 320>",
    "<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>

我不知道这是什么意思。请帮我弄清楚。

最佳答案

    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x15dd1da0 h=-&- v=-&- Keyboard:0x15db2b00.width == UIView:0x15da7b90.width - 320>",
    "<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>

它告诉你它不能同时满足所有的约束条件。

你有一个约束 <NSAutoresizingMaskLayoutConstraint:0x15dd1da0 h=-&- v=-&- Keyboard:0x15db2b00.width == UIView:0x15da7b90.width - 320> , 这表明键盘的宽度等于 UIView 的宽度在 0x15da7b90负 320(检查调试器是哪一个,如果我知道 UIView 可能导致问题的原因,我通常会查看 GUI 调试器)。

另一个冲突约束是 <NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]> , 这决定了 UIView 的宽度在 0x15da7b90 (同一个)为0。不能同时满足这个和上面那个,所以打破这个。

我看到您的第一个约束是 NSAutoresizingMaskLayoutConstraint 类型之一, 所以你可以尝试设置 setTranslatesAutoresizingMaskIntoConstraints在您的 View 中设置为 false,这可能会删除第一个约束,从而消除冲突。

其他有用的文档:

关于objective-c - 自定义键盘中的 iOS 8.3 'UIView-Encapsulated-Layout-Width',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29565284/

相关文章:

ios - 了解自动布局中的 "greater than or equal"和 "less than or equal"

ios - TextView文本未正确显示

ios - 使用自动布局将图像宽度调整为 100%,同时保持纵横比

objective-c - iOS中如何立即释放内存?

objective-c - 从 XCode 编辑器创建 Localizable.stringsdict 文件

ios - 如何通知 UICollectionView 框架更改

ios - 在 Swift 中的 ViewController 之间传递数组/对象

ios - 用于验证 API 的 OAuth2 - 无法重定向回我的应用程序

iphone - 苹果因应用内购买未实现恢复而拒绝

ios8 - 来自 PHAsset 的 NSURL