我实现了自定义键盘。它在运行 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,这可能会删除第一个约束,从而消除冲突。
其他有用的文档:
- Visual Format Language ,Xcode 在日志中使用的格式,有助于了解这种语言以更好地调试它们。
- View Debugging in Xcode , 有助于确定哪些 View 位于何处以及位于什么地址。
关于objective-c - 自定义键盘中的 iOS 8.3 'UIView-Encapsulated-Layout-Width',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29565284/