瀏覽代碼

do not use 'navigationController?' after popping self - the weak pointer will be nil

B. Petersen 5 年之前
父節點
當前提交
0609223791

+ 4 - 3
deltachat-ios/Controller/NewContactController.swift

@@ -105,9 +105,10 @@ class NewContactController: UITableViewController {
     }
 
     private func showChat(chatId: Int) {
-        let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
-        navigationController?.popToRootViewController(animated: false)
-        navigationController?.pushViewController(chatViewController, animated: true)
+        if let chatlistViewController = navigationController?.viewControllers[0] {
+            let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
+            navigationController?.setViewControllers([chatlistViewController, chatViewController], animated: true)
+        }
     }
 }
 

+ 5 - 4
deltachat-ios/Controller/NewGroupController.swift

@@ -344,9 +344,10 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
 
     // MARK: - coordinator
     private func showGroupChat(chatId: Int) {
-        let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
-        navigationController?.popToRootViewController(animated: false)
-        navigationController?.pushViewController(chatViewController, animated: true)
+        if let chatlistViewController = navigationController?.viewControllers[0] {
+            let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
+            navigationController?.setViewControllers([chatlistViewController, chatViewController], animated: true)
+        }
     }
 
     private func showPhotoPicker(delegate: MediaPickerDelegate) {
@@ -377,8 +378,8 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
     }
 
     private func onGroupMembersSelected(_ memberIds: Set<Int>) {
-        navigationController?.popViewController(animated: true)
         if let groupNameController = navigationController?.topViewController as? NewGroupController {
+            navigationController?.popViewController(animated: true)
             groupNameController.updateGroupContactIdsOnListSelection(memberIds)
         }
     }