From fe4cf5d61107373cffdf406bdfc0ccb27459bfe5 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 7 Jul 2015 15:08:06 +0800 Subject: [PATCH] longPress on ChatRightTextCell's bubble --- .../Cells/ChatLeftText/ChatLeftTextCell.swift | 3 --- .../Cells/ChatRightText/ChatRightTextCell.swift | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift b/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift index 4dee0825..de7f7919 100644 --- a/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift +++ b/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift @@ -58,11 +58,8 @@ class ChatLeftTextCell: UICollectionViewCell { } func handleLongPress(longPress: UILongPressGestureRecognizer) { - if longPress.state == .Began { - if let view = longPress.view, superview = view.superview { - view.becomeFirstResponder() let menu = UIMenuController.sharedMenuController() diff --git a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift index 749585ed..a4e3e9a7 100644 --- a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift +++ b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift @@ -42,6 +42,9 @@ class ChatRightTextCell: ChatRightBaseCell { NSUnderlineStyleAttributeName: NSNumber(integer: NSUnderlineStyle.StyleSingle.rawValue), ] + let longPress = UILongPressGestureRecognizer(target: self, action: "handleLongPress:") + textContentTextView.addGestureRecognizer(longPress) + textContentTextViewTrailingConstraint.constant = YepConfig.chatCellGapBetweenTextContentLabelAndAvatar() textContentTextViewLeadingConstraint.constant = YepConfig.chatTextGapBetweenWallAndContentLabel() @@ -53,6 +56,18 @@ class ChatRightTextCell: ChatRightBaseCell { bubbleBodyImageView.addGestureRecognizer(tap) } + func handleLongPress(longPress: UILongPressGestureRecognizer) { + if longPress.state == .Began { + if let view = longPress.view, superview = view.superview { + view.becomeFirstResponder() + + let menu = UIMenuController.sharedMenuController() + menu.setTargetRect(view.frame, inView: superview) + menu.setMenuVisible(true, animated: true) + } + } + } + func tapMediaView() { mediaTapAction?() }