0

I'm using auto layout in my project and I get the following message in the console window:

Attempting to get auto layout values with nil engine. Affected view:

This happens if I try to update my view hierarchy in observeValueForKeyPath:ofObject:change:context:

Does anyone know what the reason for this behavior can be?

Marcin Kuptel
  • 2,674
  • 1
  • 17
  • 22

1 Answers1

0

It sounds like you're updating your view hierarchy at the wrong time. I suspect that somewhere in the view lifecycle your KVO is being invoked before everything is actually set up and ready for new views to be added. I realize this may not be appropriate for your project but I suggest re-thinking your task in terms of the supported lifecycle events like viewDidLoad or viewWillLayoutSubviews.

If the only way for you to detect the event you're interested in is truly KVO you may be able to get away with noting that something happened by setting a flag, and then updating your view hierarchy later in the cycle.

James
  • 1,118
  • 7
  • 13