Эх сурвалжийг харах

use viewWillTransition in order to dect screen orientation changes to relayout chat message cells

cyberta 5 жил өмнө
parent
commit
92c671a077

+ 6 - 15
deltachat-ios/Controller/ChatViewController.swift

@@ -115,13 +115,6 @@ class ChatViewController: MessagesViewController {
                                        selector: #selector(setTextDraft),
                                        name: UIApplication.willResignActiveNotification,
                                        object: nil)
-        notificationCenter.addObserver(self, selector: #selector(rotated),
-                                       name: UIDevice.orientationDidChangeNotification,
-                                       object: nil)
-    }
-
-    deinit {
-        NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
     }
 
     private func startTimer() {
@@ -244,7 +237,12 @@ class ChatViewController: MessagesViewController {
             if self.showCustomNavBar, let titleView = self.navigationItem.titleView as? ChatTitleView {
                 titleView.hideLocationStreamingIndicator() }},
                             completion: { (_) -> Void in
-                                self.updateTitle(chat: DcChat(id: self.chatId)) })
+                                self.updateTitle(chat: DcChat(id: self.chatId))
+                                self.messagesCollectionView.reloadDataAndKeepOffset()
+                                if self.isLastSectionVisible() {
+                                    self.messagesCollectionView.scrollToBottom(animated: true)
+                                }
+        })
         super.viewWillTransition(to: size, with: coordinator)
     }
 
@@ -389,13 +387,6 @@ class ChatViewController: MessagesViewController {
         }
     }
 
-    @objc private func rotated() {
-        self.messagesCollectionView.reloadDataAndKeepOffset()
-        if self.isLastSectionVisible() {
-            self.messagesCollectionView.scrollToBottom(animated: true)
-        }
-    }
-
     private func configureMessageMenu() {
         var menuItems: [UIMenuItem]