Objective c iOS 8.3';UIView封装布局宽度';在自定义键盘中

Objective c iOS 8.3';UIView封装布局宽度';在自定义键盘中,objective-c,ios8,autolayout,custom-keyboard,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; (

我实现了一个自定义键盘。它在运行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)]>
下面列表中可能至少有一个约束是您不想要的约束。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
""
)
将尝试通过打破约束进行恢复

我不知道这意味着什么。请帮我弄明白。

我在做键盘扩展时也有过这样的经历

这是关于UIInputViewControllerinputView对inputView的父视图具有UIViewAutoResisingFlexible

并将屏蔽转换为具有名称的封装约束

<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>

在您的日志中,还有另一个转换的约束(来自屏蔽),因此我认为您可以使用它轻松地管理视图。在我看来,您必须使用NSConstraint(宽度和高度…)

我曾试图从inputView中删除屏蔽,但这给我管理位置和边界带来了更多困难

另外,当我在旧版应用程序(iPhone 6/6+不支持)上运行键盘时,我遇到了这种情况

每次我旋转屏幕时,关于高度的限制都会被像你这样的圆木挡住


如果你有其他问题或我的回答不充分,请再次告诉我

nsautoresizingmasklayoutconstraint
这意味着您没有正确设置自动布局约束。尝试将其正确设置,然后您的问题将得到解决

以下列表中可能至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
    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)]>
( "", "" ) 将尝试通过打破约束进行恢复
它告诉您它不能同时满足所有约束

您有一个约束条件
,它规定键盘的宽度等于
0x15da7b90
UIView
的宽度减去320(检查调试器这是哪一个,如果我知道是什么
UIView
可能导致问题,我通常会查看GUI调试器)

另一个冲突约束是
,它规定
0x15da7b90
(同一个)处
UIView
的宽度为0。它不能同时满足这个和上面的一个,所以它破坏了这个

我发现您的第一个约束属于类型
nsAutoResizengMaskLayoutConstraint
,因此您可以尝试在视图中将
setTranslatesAutoResizengMaskToConstraints
设置为false,这可能会删除第一个约束,从而消除冲突

其他有用的文档:

  • ,Xcode在日志中使用的格式,有助于了解该语言以更好地调试它们
  • ,有助于确定哪些视图位于何处以及位于何处

事实上,我在8.2设备上看到过这条消息,根据我的经验,它实际上表明您的约束得到了尊重,并且您的高度设置正确。您是否仍然拥有8.3设备的完全访问权限?您在
UIInputView
中是否有其他具有自动布局约束的视图?@BenPious很遗憾,高度设置也不正确。或者您是否向inputView添加了自动屏蔽视图,如collectionview?