【问题标题】:UIPresentationController -- can I update the presented view controller's frame after presentation?UIPresentationController——我可以在展示后更新展示的视图控制器的框架吗?
【发布时间】:2016-06-03 12:32:53
【问题描述】:
我正在使用自定义 UIPresentationController 子类来管理 UIViewController 的呈现。我覆盖- (CGRect)frameOfPresentedViewInContainerView 以提供一个从containerView 的边界插入的框架。
现在,在对presentedViewController 进行一些用户操作后,我想更改presentViewController 的框架。我的问题是:有没有一种“自然”的方式来做到这一点??
展示后如何调整展示的ViewController的框架?
【问题讨论】:
标签:
ios
uipresentationcontroller
【解决方案1】:
所以我这样做的方法是执行以下操作:
我从<UIContentContainer>添加了以下方法:
- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
然后我简单地更新了我的presentedViewController 上的preferredContentSize,获得了回调,并在UIPresentationController 中动画帧更新。
【解决方案2】:
- 在财产中保留 NAV 或 VC 的实例(保存)
- 以某种 x 大小呈现(也可以在 modalPresentationStyle 中更改为 popover/fullscreen)
- [在用户操作后] 关闭显示的导航或 vc
- 显示保存的 VC/NAV,即更改为 Y 尺寸后(可以)
存储实例意味着再次出现在同一个地方。
使用如下适当的动画滚动来平滑过渡
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;