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

2

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?

Homan answered 22/2, 2016 at 7:3 Comment(0)
H
10

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.

Homan answered 22/2, 2016 at 15:40 Comment(0)
A
-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;

Anthracoid answered 22/2, 2016 at 7:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.