I have a UIViewController which is pushed from navigationController that uses custom left/back button with interactivePopGestureRecognizer, however, when I click a row from tableview my app sometimes stucks and after pressing home button and going background then reopening the app, it continues but swipe action of navigationcontroller becomes weird. Here is the video of what am I saying;
//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 can be the reason for that?
1 Answers
Answers 1
Can you try changing your 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 this one ?
self.navigationController?.pushViewController(chatVC, animated: true) I think it might solve your problem. Hope it works !
0 comments:
Post a Comment