Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPresentationController -- can I update the presented view controller's frame after presentation?

I'm using a custom UIPresentationController subclass to manage the presentation of a UIViewController. I'm overriding - (CGRect)frameOfPresentedViewInContainerView to provide a frame that is inset from the bounds of the containerView.

Now, after some user action on the presentedViewController, I would like to change the frame of the presentedViewController. My question is: Is there a 'natural' way to do this??

How can I adjust the frame of a presentedViewController after it has been presented?

like image 983
Sean Danzeiser Avatar asked Feb 22 '16 07:02

Sean Danzeiser


People also ask

What is the purpose of the uipresentationcontroller class?

The UIPresentationController class defines specific entry points for manipulating the view hierarchy when presenting a view controller. When a view controller is about to be presented, UIKit calls the presentation controller’s presentationTransitionWillBegin () method.

What is a presentation controller in UIKit?

An object that manages the transition animations and the presentation of view controllers onscreen. From the time a view controller is presented until the time it is dismissed, UIKit uses a presentation controller to manage various aspects of the presentation process for that view controller.

What is the transitioning delegate for the presented view controller?

The presented view controller has a transitioning delegate that’s responsible for loading the UIPresentationController and the presentation and dismissal animation controllers. That delegate is an object that conforms to UIViewControllerTransitioningDelegate.

How is the presentation process managed by a presentation controller?

The presentation process managed by a presentation controller is divided into three phases: The presentation phase involves moving the new view controller onscreen through a series of transition animations. The management phase involves responding to environment changes (such as device rotations) while the new view controller is onscreen.


1 Answers

So the way I went about this was to do the following:

I added implemented the following method from <UIContentContainer>:

- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container 

I then simply updated the preferredContentSize on my presentedViewController, got the callback, and animated the frame update within the UIPresentationController.

like image 194
Sean Danzeiser Avatar answered Oct 21 '22 12:10

Sean Danzeiser