使用现在和全屏

发布于 2025-02-05 20:42:21 字数 1571 浏览 2 评论 0原文

我正在使用.present呈现视图。 当应用程序加载时,第一个视图是登录图,该视图是从MainView加载的,该视图是顶部控制器的MainView。

所有视图均以专用方法呈现。我可以清楚地看到,目前尚无其他观点。

我不希望视图被轻扫不可忽视。为此,我使用.fullscreen。当我使用全屏时,我会看到错误/警告“ 不平衡的调用开始/结束外观过渡”。使用“全屏”,在演示文稿完成后,将删除属于呈现视图控制器的视图。我怀疑这是消息的原因。

如果我使用.overfullscreen我看不到此消息。使用.overfullscreen在演示文稿结束时,所呈现内容下方的视图不会从视图层次结构中删除。

任何人都可以确认在FullScreen过渡之后删除视图的内置动作是此消息的原因,以及我如何在不触发此消息的情况下使用FullScreen

使用Swift 5和Xcode 13.4.1,Mac OS 12.2.1

func presentView(viewInstance: UIViewController){
    if let topController = UIApplication.topViewController() {
        viewInstance.modalPresentationStyle = . fullScreen
        topController.present(viewInstance, animated: false, completion: nil)
     }
}

extension UIApplication {
    class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
        if let navigationController = controller as? UINavigationController {
            return topViewController(controller: navigationController.visibleViewController)
        }
        if let tabController = controller as? UITabBarController {
            if let selected = tabController.selectedViewController {
                return topViewController(controller: selected)
            }
        }
        if let presented = controller?.presentedViewController {
            return topViewController(controller: presented)
        }
        return controller
    }
}

I am presenting views with .present.
When the app loads the first view is loginView which is loaded from mainView which is the top controller.

All views are presented in a dedicated method. I can see clearly that at this time no other views are being presented.

I do not want views to be dismissible with a swipe. To achieve this I am using .fullScreen. When I use full screen I see the error/warning "unbalanced calls to begin/end appearance transitions". Using 'fullScreen' the views belonging to the presenting view controller are removed after the presentation completes. I suspect that this is the cause of the message.

If I use .overFullScreen I do not see this message. Using .overFullScreen the views beneath the presented content are not removed from the view hierarchy when the presentation finishes.

Can anyone confirm that built in action of removing views following the fullScreen transition are the cause of this message and how can I use fullScreen without triggering this message.

Using Swift 5 and Xcode 13.4.1, Mac OS 12.2.1

func presentView(viewInstance: UIViewController){
    if let topController = UIApplication.topViewController() {
        viewInstance.modalPresentationStyle = . fullScreen
        topController.present(viewInstance, animated: false, completion: nil)
     }
}

extension UIApplication {
    class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
        if let navigationController = controller as? UINavigationController {
            return topViewController(controller: navigationController.visibleViewController)
        }
        if let tabController = controller as? UITabBarController {
            if let selected = tabController.selectedViewController {
                return topViewController(controller: selected)
            }
        }
        if let presented = controller?.presentedViewController {
            return topViewController(controller: presented)
        }
        return controller
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文