繁体   English   中英

presentViewController隐藏presentingViewController

[英]presentViewController hides presentingViewController

有没有一种方法可以在iOS中呈现ViewController,同时保持呈现ViewController可见? 现在,动画结束后,PresentingViewController似乎被隐藏了。

使用UIModalPresentationStyle的值来控制它。

UIModalPresentationPageSheetUIModalPresentationFormSheet将导致演示,这些演示将在下面留下大量的演示视图控制器。

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

例如

presentedViewController.modalPresentationStyle = UIModalPresentationFormSheet;

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

节目:

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
        })
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM