Преглед на файлове

ensure text view will update its size on rotation and keyboard change

cyberta преди 4 години
родител
ревизия
4fbeda309b
променени са 1 файла, в които са добавени 5 реда и са изтрити 5 реда
  1. 5 5
      deltachat-ios/Chat/Views/ChatInputBar.swift

+ 5 - 5
deltachat-ios/Chat/Views/ChatInputBar.swift

@@ -71,9 +71,7 @@ public class ChatInputBar: InputBarAccessoryView {
         if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
             let keyboardRectangle = keyboardFrame.cgRectValue
             keyboardHeight = keyboardRectangle.height - intrinsicContentSize.height
-            maxTextViewHeight = calculateMaxTextViewHeight()
-            logger.debug("keyboard height: \(keyboardHeight) - intrinsic content size:  \(intrinsicContentSize.height)")
-            forceMaxTextViewHeightForHorizontalLayout()
+            updateTextViewHeight()
         }
     }
 
@@ -81,15 +79,17 @@ public class ChatInputBar: InputBarAccessoryView {
         super.traitCollectionDidChange(previousTraitCollection)
         if (self.traitCollection.verticalSizeClass != previousTraitCollection?.verticalSizeClass)
                 || (self.traitCollection.horizontalSizeClass != previousTraitCollection?.horizontalSizeClass) {
-            forceMaxTextViewHeightForHorizontalLayout()
+            updateTextViewHeight()
         }
     }
 
-    private func forceMaxTextViewHeightForHorizontalLayout() {
+    private func updateTextViewHeight() {
+        maxTextViewHeight = calculateMaxTextViewHeight()
         if keyboardHeight > 0, UIApplication.shared.statusBarOrientation.isLandscape {
             setShouldForceMaxTextViewHeight(to: true, animated: false)
         } else if shouldForceTextViewMaxHeight {
             setShouldForceMaxTextViewHeight(to: false, animated: false)
         }
+        invalidateIntrinsicContentSize()
     }
 }