From e11f1f026e0dbadf784570693a1a1d306a4cce2a Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 20 Jul 2016 11:16:34 +0800 Subject: [PATCH 1/3] check previewTransitionViews if hide --- ...sationViewController+PhotosViewControllerDelegate.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift b/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift index 95c40cc85..f8d7042d9 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift @@ -22,7 +22,12 @@ extension ConversationViewController: PhotosViewControllerDelegate { } else if let previewMessagePhoto = photo as? PreviewMessagePhoto { if let index = previewMessagePhotos.indexOf(previewMessagePhoto) { - return previewTransitionViews?[index] + if let view = previewTransitionViews?[index] { + let rect = view.convertRect(view.frame, toView: view) + if rect.minY >= 64 && rect.maxY < messageToolbar.frame.minY { + return view + } + } } } From 927751ec74faffb0075171e3d8f357df821373f8 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 20 Jul 2016 11:22:14 +0800 Subject: [PATCH 2/3] only enable init view in transitionViews --- ...rsationViewController+CollectionView.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift b/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift index 3fba17a7d..80f14e842 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift @@ -420,6 +420,7 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi return } + /* let transitionViews: [UIView?] = mediaMessages.map({ if let index = messages.indexOf($0) { let cellIndex = index - displayedMessagesRange.location @@ -434,6 +435,25 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi return nil }) + */ + let transitionViews: [UIView?] = mediaMessages.map({ + if let index = messages.indexOf($0) { + if index == messageIndex { + let cellIndex = index - displayedMessagesRange.location + let cell = conversationCollectionView.cellForItemAtIndexPath(NSIndexPath(forItem: cellIndex, inSection: Section.Message.rawValue)) + + if let leftImageCell = cell as? ChatLeftImageCell { + return leftImageCell.messageImageView + } else if let rightImageCell = cell as? ChatRightImageCell { + return rightImageCell.messageImageView + } + } else { + return nil + } + } + + return nil + }) self.previewTransitionViews = transitionViews From 6afe2d011600d85c7d0f00a8fc9504b4a177bcbc Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 20 Jul 2016 11:22:56 +0800 Subject: [PATCH 3/3] clear --- ...nversationViewController+CollectionView.swift | 16 ---------------- ...Controller+PhotosViewControllerDelegate.swift | 7 +------ 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift b/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift index 80f14e842..bc658802d 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController+CollectionView.swift @@ -420,22 +420,6 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi return } - /* - let transitionViews: [UIView?] = mediaMessages.map({ - if let index = messages.indexOf($0) { - let cellIndex = index - displayedMessagesRange.location - let cell = conversationCollectionView.cellForItemAtIndexPath(NSIndexPath(forItem: cellIndex, inSection: Section.Message.rawValue)) - - if let leftImageCell = cell as? ChatLeftImageCell { - return leftImageCell.messageImageView - } else if let rightImageCell = cell as? ChatRightImageCell { - return rightImageCell.messageImageView - } - } - - return nil - }) - */ let transitionViews: [UIView?] = mediaMessages.map({ if let index = messages.indexOf($0) { if index == messageIndex { diff --git a/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift b/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift index f8d7042d9..95c40cc85 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController+PhotosViewControllerDelegate.swift @@ -22,12 +22,7 @@ extension ConversationViewController: PhotosViewControllerDelegate { } else if let previewMessagePhoto = photo as? PreviewMessagePhoto { if let index = previewMessagePhotos.indexOf(previewMessagePhoto) { - if let view = previewTransitionViews?[index] { - let rect = view.convertRect(view.frame, toView: view) - if rect.minY >= 64 && rect.maxY < messageToolbar.frame.minY { - return view - } - } + return previewTransitionViews?[index] } }