11

I have implemented a custom keyboard. It works fine on a device which runs iOS 8.2.

However, when I run the same code on a device with iOS 8.3 I get the following warnings and the height of the keyboard is not set properly:

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)]>

I have no idea what this means. Please help me figure it out.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
Neelesh
  • 3,673
  • 8
  • 47
  • 78
  • I've actually seen this message on 8.2 devices, in my experience it actually indicates that your constraint *has* been respected and your height has been set correctly. Do you still have full access on on your 8.3 device? Do you have any other views in the `UIInputView` with autolayout constraints? – Ben Pious Apr 10 '15 at 16:56
  • @BenPious Unfortunately height wasn't set properly either. – Neelesh Apr 11 '15 at 08:23

3 Answers3

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)]>

It is telling you that it can't satisfy all constraints at once.

You have a constraint <NSAutoresizingMaskLayoutConstraint:0x15dd1da0 h=-&- v=-&- Keyboard:0x15db2b00.width == UIView:0x15da7b90.width - 320>, which dictates the width of the keyboard equals the width of the UIView at 0x15da7b90 minus 320 (check the debugger which one this is, I usually look at the GUI debugger if I know what UIViews might be causing the problem).

The other conflicting constraint is <NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>, which dictates the width of the UIView at 0x15da7b90 (same one) to be 0. It cannot satisfy both this one and the one above, so it breaks this one.

I see that your first constraint is one of the type NSAutoresizingMaskLayoutConstraint, so you can try to set setTranslatesAutoresizingMaskIntoConstraints to false on your view, which will probably remove the first constraint, thus removing the conflict.

Other helpful documentation:

vrwim
  • 13,020
  • 13
  • 63
  • 118
0

I also had that experiences when I made Keyboard Extension.

That is about that the inputView of UIInputViewController has UIViewAutoresizingFlexible to parentView of inputView

And the masking is translated into encapsulated constraint with the name

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

In your logs, there is another translated constraint(from masking), so I think you use it for managing views easily. In my opinion, you have to use NSConstraint(width and height ...)

I'd tried to remove the masking from the inputView, but it gave me much more difficulties about managing locations and bounds.

Also, I met this situation when I run my keyboard on legacy app(not supported to iPhone 6/6+).

Each time I rotate the screen, the constraint about the height is blocked with the logs like yours.

If you have another question or my answer is not adequate, tell me again.

Jeonghan Joo
  • 225
  • 2
  • 10
0

NSAutoresizingMaskLayoutConstrain this means you have not set auto layout constraints properly. Try to set it properly then your problem will be solved

Nischal Hada
  • 3,230
  • 3
  • 27
  • 57