【问题标题】:ModalViewController frame movingModalViewController 框架移动
【发布时间】:2012-08-10 17:09:54
【问题描述】:

我不确定我是否可以这样做,但让我们尝试一下比我更聪明的人。

我希望能够通过拖动来移动呈现控制器的框架。我期待看到我调用了 [self presentModalViewController:anotherVC animated:YES]; 的控制器。下面介绍的一个。我看到的是白色背景。

为了在不显示模态视图控制器的情况下实现此功能,我可以添加子视图,即:

[self.view addSubview:anotherVC.view];

但是有没有办法移动模态呈现的视图控制器并能够看到这个模态控制器所在的视图?

【问题讨论】:

    标签: ios view modalviewcontroller


    【解决方案1】:

    如果你需要在模态视图后面显示父视图,那么你可以使用这段代码:

    将您的anotherVC.view.frame 设置为小于您的父视图。

    anotherVC.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:anotherVC animated:YES]; 
    

    但父视图的可见部分将变暗以防止交互。

    UIModalPresentationFormSheet

    The width and height of the presented view are smaller than those of the screen and the view is centered onscreen. If the device is in a
    

    横向且键盘可见,位置 视图向上调整,使视图保持可见。全部揭开 区域变暗以防止用户与其交互。

    Modal Presentation Styles

    【讨论】:

    • 我不确定这是否可行。我试图改变 origin.y 并且我所拥有的只是白色背景。我解决问题的方法是制作父视图控制器的屏幕截图并将其用作我的模态视图控制器的背景(当然作为 UIIMageView)。
    猜你喜欢
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-15
    • 2011-08-29
    相关资源
    最近更新 更多