UINavigationController crashes UI on swipe action (black screen, video inside)

I have UIViewControllerone that is popped out navigationController, which uses a custom left / back button using interactivePopGestureRecognizer, however, when I click a row from a table, my application sometimes holds even after I press the home button and go to the background, and then opens the application again. it continues, but the swipe action of the navigation controller becomes weird. Here is a video of what I'm saying;

https://streamable.com/xvl38

//This is the function that I use to open chat from tableview on didSelectRowAt

func openChat(with nick: String, isFromConversationList: Bool) {
        guard let chatVC = UIStoryboard(name: "Main", bundle: .main).instantiateViewController(withIdentifier: "ChatViewController") as? ChatViewController,
            let rootNC = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController else {
                return
        }
        rootNC.pushViewController(chatVC, animated: true)
}

override func viewDidLoad() {
    super.viewDidLoad()
    navigationController?.interactivePopGestureRecognizer?.delegate = nil
}
override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)   
    self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)
    self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false

}

What could be the reason for this?

+6
source share
1 answer

Can you try changing the code from this

guard let chatVC = UIStoryboard(name: "Main", bundle: .main).instantiateViewController(withIdentifier: "ChatViewController") as? ChatViewController,
     let rootNC = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController else {
     return
}
rootNC.pushViewController(chatVC, animated: true)

to that?

self.navigationController?.pushViewController(chatVC, animated: true)

, . , !

0

All Articles