Appearance Relay Method is called in the container user controller

I follow the Apple guide to create my own custom container view controller. It seems to work just fine, except for one annoying problem.

How exactly do I indicate when my view controller will receive calls to viewWillAppear: and viewDidAppear: (and their disappear )?

Let's say I have a fantastic animation of a child sliding into a parent or something like that. Naturally, I would like viewWillAppear:YES called at the beginning of the animation and viewDidAppear:YES at the end. However, by default, both viewWillAppear:NO and viewDidAppear:NO are called at the same time when my child view is added to the parent view.

Now I know that there are beginAppearanceTransition:animated: and endAppearanceTransition added in iOS 6, but I would like to support iOS 5. It also seems to be intended for use in advanced cases:

After adding a child to the container, the container automatically fast-forwards and a callback appears in the child view of the controllers as soon as an event occurs that requires the message to be forwarded. This is usually the behavior you want as it ensures that all events are sent correctly. However, sometimes the default behavior may send these events in an order that does not make sense to your container. For example, if several children change their viewing state at the same time, you might want to consolidate the changes so that the appearance callbacks occur simultaneously in a more logical order. To do this, you change your container class to be responsible for the appearance or rotation callbacks.

There is also a transitionFromViewController:toViewController:duration:options:animations:completion: method, which calls the appropriate appearance methods, but this requires two view controllers and, as a rule, looks out of place. Of course, I can do the trick and feed him a mannequin, but seriously ...

Is there something I am missing? Any help would be greatly appreciated.

+4
source share
1 answer

And the answer is pretty funny.

The docs may say that beginAppearanceTransition:animated: and endAppearanceTransition are available in iOS 6+, but this is not the case. These methods are great for use in iOS 5:

 - (void)beginAppearanceTransition:(BOOL)isAppearing animated:(BOOL)animated __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); - (void)endAppearanceTransition __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); 

This answer to the question also says the same thing. The case is settled!

+3
source

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


All Articles