8

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?

Vvk
  • 4,031
  • 29
  • 51
Sean Danzeiser
  • 9,141
  • 12
  • 52
  • 90

2 Answers2

9

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.

Sean Danzeiser
  • 9,141
  • 12
  • 52
  • 90
-1
  1. keep instance of NAV or VC in property (save)
  2. Present in some x size (can also be change in modalPresentationStyle to popover/fullscreen )
  3. [after user action] dismiss the presented nav or vc
  4. present saved VC/NAV i.e after changing to Y size (can be )

Storing instance means present in same place again.

Use proper animation scroll like below to smooth transition

vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

mkumar
  • 111
  • 1
  • 10