"Auto-linking still required ..." failed to return to the main view controller

My application starts with the main menu, which is a subclass of the UIViewController called LVSMainViewController . It is built into the UINavigationController , which is set as the initial VC in the storyboard. LVSMainViewController implements -viewDidLayoutSubviews .

Pressing the button leads the user to another section of the application (another VC). The user returns to the main menu with the button connected to the press. But when the application loads the VC main menu again, it crashes with the message:

2014-08-28 16: 11: 14.122 * Approval error in - [UIView layoutSublayersOfLayer:], / SourceCache / UIKit_Sim / UIKit-2935.137 / UIView.m: 8803

2014-08-28 16: 11: 14.257 * Application termination due to the uncaught exception "NSInternalInconsistencyException", reason: "Auto-linking is still required after sending -viewDidLayoutSubviews to the view controller. The LVSMainViewController implementation must send -layoutSubviews to the view to call automatic layout. '

Other posts in SO report the same error when programming automatic layout restrictions (I do not, although I use automatic layout in the storyboard) and / or when using UITableView (which I do not use either in the VC main menu or in VC, to to which it goes, although I use it elsewhere in the application). (See here or here .)

Other puzzle pieces:

  • I tried adding [self.view layoutSubviews]; at the end is -viewDidLayoutSubviews . When I do this, it does not fall. But it seems like this is bad, as Apple's documentation says

    You should not call this method directly. If you want layout updates, call the setNeedsLayout method instead to do this earlier for the next drawing update.

  • If I add [self.view setNeedsLayout]; at the end -viewDidLayoutSubviews , the application crashes with it first loads the VC main menu, and not when I leave it and return it.

What could be the reason for this?

+6
source share
2 answers

The crash is magically fixed in Xcode 6.0.1.

-4
source

The reason the magic is fixed is likely because you are now using iOS 8. Have you tried running this code on iOS7?

You are close to the answer by calling [self.view layoutSubviews] .

Try calling [self.view layoutIfNeeded] .

See these posts:

Autostart and view in view mode

Auto Layout Error

+14
source

Source: https://habr.com/ru/post/974519/


All Articles