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

Nee*_*esh 11 objective-c autolayout ios8 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)]>
Run Code Online (Sandbox Code Playgroud)

我不知道这是什么意思.请帮我搞清楚.

vrw*_*wim 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)]>
Run Code Online (Sandbox Code Playgroud)

它告诉你它无法同时满足所有约束。

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

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

我看到您的第一个约束是 type 之一NSAutoresizingMaskLayoutConstraint,因此您可以尝试setTranslatesAutoresizingMaskIntoConstraints在视图上设置为 false,这可能会删除第一个约束,从而消除冲突。

其他有用的文档: