presentViewController隐藏presentViewController

时间:2013-12-28 13:59:46

标签: ios objective-c uiviewcontroller modalviewcontroller

有没有办法在iOS中呈现ViewController,同时保持呈现的ViewController可见?现在,一旦动画结束,PresentingViewController似乎就会被隐藏。

2 个答案:

答案 0 :(得分:1)

使用UIModalPresentationStyle中的值来控制此值。

UIModalPresentationPageSheetUIModalPresentationFormSheet将导致演示文稿在下方留下一定数量的呈现视图控制器。

呈现的视图控制器上设置modalPresentationStyle

e.g

presentedViewController.modalPresentationStyle = UIModalPresentationFormSheet;

[presentingViewController presentViewController:presentedViewController animated:YES completion:nil];

答案 1 :(得分:0)

显示:

if let popupVC = storyboard.instantiateViewControllerWithIdentifier("PopupVC") as? PopupVC
    {
        var frame = UIScreen.mainScreen().bounds
        frame.origin.y = frame.size.height
        overlayWindow = UIWindow(frame: frame)

        popupVC.overlayWindow = overlayWindow
        overlayWindow.windowLevel = UIWindowLevelAlert
        overlayWindow.rootViewController = popupVC

        overlayWindow.makeKeyAndVisible()

        UIView.animateWithDuration(0.3, animations:
        {
            self.overlayWindow.frame.origin.y = 0
        })
    }

在PopupVC中隐藏

 if let window = overlayWindow
    {
        UIView.animateWithDuration(0.3, animations: {
            window.frame.origin.y = window.frame.height
        }, completion: { (finished) -> Void in
            self.overlayWindow = nil
        })
    }