longPress on ChatRightTextCell's bubble

This commit is contained in:
nixzhu
2015-07-07 15:08:06 +08:00
parent 3927821737
commit fe4cf5d611
2 changed files with 15 additions and 3 deletions
@@ -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()
@@ -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?()
}