From e9b3a7065fb0916a5d35ae9bc508060f4ef1c8f4 Mon Sep 17 00:00:00 2001 From: Nathan Tannar Date: Thu, 28 Feb 2019 22:33:27 -0800 Subject: [PATCH] Quick fix for #993 --- .../AdvancedExampleViewController.swift | 10 +++++++++- .../Controllers/MessagesViewController+Keyboard.swift | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Example/Sources/View Controllers/AdvancedExampleViewController.swift b/Example/Sources/View Controllers/AdvancedExampleViewController.swift index 4e0d7774..d9274957 100644 --- a/Example/Sources/View Controllers/AdvancedExampleViewController.swift +++ b/Example/Sources/View Controllers/AdvancedExampleViewController.swift @@ -207,8 +207,16 @@ final class AdvancedExampleViewController: ChatViewController { $0.tintColor = .primaryColor }.onDeselected { $0.tintColor = UIColor(white: 0.8, alpha: 1) - }.onTouchUpInside { _ in + }.onTouchUpInside { print("Item Tapped") + let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) + let action = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + actionSheet.addAction(action) + if let popoverPresentationController = actionSheet.popoverPresentationController { + popoverPresentationController.sourceView = $0 + popoverPresentationController.sourceRect = $0.frame + } + self.navigationController?.present(actionSheet, animated: true, completion: nil) } } diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index ce6cf284..5a3777a1 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -56,7 +56,7 @@ extension MessagesViewController { guard !isMessagesControllerBeingDismissed else { return } guard let keyboardStartFrameInScreenCoords = notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? CGRect else { return } - guard !keyboardStartFrameInScreenCoords.isEmpty else { + guard !keyboardStartFrameInScreenCoords.isEmpty || UIDevice.current.userInterfaceIdiom != .pad else { // WORKAROUND for what seems to be a bug in iPad's keyboard handling in iOS 11: we receive an extra spurious frame change // notification when undocking the keyboard, with a zero starting frame and an incorrect end frame. The workaround is to // ignore this notification.