UINavigationController - auto view detection

I read in the Apple documentation about the resizing behavior of the UINavigationController, and so far this has not been a big problem.

I have the following code to customize my UINavigationController view:

navController.view.frame = CGRectMake(0, 40, 320, 420);

and this is enough until the view is closed by a modal view, after which the image will be resized to the default size somewhere between calls viewWillAppearand viewDidAppear(since the UINavigationController inherits the UIViewController).

I try to keep the banner visible above the UINavigationController (in the remaining free space of 40 by 320), but this banner is constantly hiding, as described above.

Is there a way to suppress the resizing behavior of a UINavigationController without subclassing the UIViewController?

+3
source share
2 answers

In the interface designer, you can uncheck the box with automatic resizing.

In code, this

[myNavController.view setAutoresizesSubviews: NO];
+2
source

I would try

myNavController.superview.autoresizesSubviews = NO

and obviously check myNavController.autoresizingMask

As a last resort, subclass its supervisor and reimplement layoutSubviews

0
source

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


All Articles