iOS 8.3 'UIView-Encapsulated-Layout-Width' 自定义键盘
iOS 8.3 'UIView-Encapsulated-Layout-Width' in Custom Keyboard
我实现了自定义键盘。它在 运行s 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)]>
我不知道这是什么意思。请帮我解决一下。
我在做Keyboard Extension的时候也有过这样的经历
也就是说UIInputViewController的inputView对inputView[的parentViewUIViewAutoresizingFlexible有UIViewAutoresizingFlexible =11=]
并且掩码被翻译成名称为
的封装约束
<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>
在您的日志中,还有另一个转换的约束(来自屏蔽),因此我认为您可以使用它轻松管理视图。在我看来,你必须使用 NSConstraint(width and height ...)
我曾尝试从 inputView 中删除遮罩,但它给我带来了更多管理位置和边界的困难。
此外,我在旧应用程序上 运行 我的键盘时遇到了这种情况(iPhone 6/6+ 不支持)。
我每次旋转屏幕时,关于高度的限制都被像你这样的日志屏蔽了。
如果您还有其他问题或我的回答不充分,请再次告诉我。
NSAutoresizingMaskLayoutConstrain
这意味着您没有正确设置自动布局约束。尝试正确设置它,那么您的问题将得到解决
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
设置为 false,这可能会删除第一个约束,从而删除冲突。
其他有用的文档:
- Visual Format Language,Xcode在日志中使用的格式,有助于了解这种语言以更好地调试它们。
- View Debugging in Xcode,有助于确定哪些视图位于何处以及位于什么地址。
我实现了自定义键盘。它在 运行s 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)]>
我不知道这是什么意思。请帮我解决一下。
我在做Keyboard Extension的时候也有过这样的经历
也就是说UIInputViewController的inputView对inputView[的parentViewUIViewAutoresizingFlexible有UIViewAutoresizingFlexible =11=]
并且掩码被翻译成名称为
的封装约束<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>
在您的日志中,还有另一个转换的约束(来自屏蔽),因此我认为您可以使用它轻松管理视图。在我看来,你必须使用 NSConstraint(width and height ...)
我曾尝试从 inputView 中删除遮罩,但它给我带来了更多管理位置和边界的困难。
此外,我在旧应用程序上 运行 我的键盘时遇到了这种情况(iPhone 6/6+ 不支持)。
我每次旋转屏幕时,关于高度的限制都被像你这样的日志屏蔽了。
如果您还有其他问题或我的回答不充分,请再次告诉我。
NSAutoresizingMaskLayoutConstrain
这意味着您没有正确设置自动布局约束。尝试正确设置它,那么您的问题将得到解决
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
设置为 false,这可能会删除第一个约束,从而删除冲突。
其他有用的文档:
- Visual Format Language,Xcode在日志中使用的格式,有助于了解这种语言以更好地调试它们。
- View Debugging in Xcode,有助于确定哪些视图位于何处以及位于什么地址。