首页 > 解决方案 > 在点击通知时弹出弹出问题(深度链接)

问题描述

我已经在屏幕上展示了一个控制器,现在单击主页按钮。然后我需要在使用深度链接点击通知后展示另一个控制器。当应用程序进入前台时,新的控制器也不会出现,之前的控制器也会被解散。也低于警告:-

Attempt to present <NewController> on <PreviousController> whose view is not in the window hierarchy!

我正在使用下面的代码来呈现。

controller.transitioningDelegate = myDelegateForTransition
        controller.modalPresentationStyle = .custom
        controller.modalPresentationCapturesStatusBarAppearance = true
viewControllerFromPresent.present(controller, animated: true, completion: {
            completionHandler?()
        })

标签: iosswiftpresentmodalviewcontrollerpresentviewcontrolleruiview-hierarchy

解决方案


我通过将 controller.modalPresentationStyle 从 custom 更改为 overCurrentContext 来解决它。

controller.transitioningDelegate = myDelegateForTransition
    controller.modalPresentationStyle = .overCurrentContext
    controller.modalPresentationCapturesStatusBarAppearance = true
viewControllerFromPresent.present(controller, animated: true, completion: {
        completionHandler?()
    })

推荐阅读