Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

Commit

Permalink
refine UIMenuController display. #458, #254, #463, #393
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesquires committed Sep 1, 2014
1 parent 30bce9b commit 3bfa3fd
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions JSQMessagesViewController/Controllers/JSQMessagesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -632,25 +632,9 @@ - (void)jsq_didReceiveMenuWillShowNotification:(NSNotification *)notification
[menu setMenuVisible:NO animated:NO];

JSQMessagesCollectionViewCell *selectedCell = (JSQMessagesCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:self.selectedIndexPathForMenu];
CGRect selectedCellFrame = [self.collectionView convertRect:selectedCell.frame toView:self.view];
CGRect selectedCellMessageBubbleFrame = [selectedCell convertRect:selectedCell.messageBubbleContainerView.frame toView:self.view];

BOOL menuIsAboveCell = CGRectGetMinY(menu.menuFrame) < CGRectGetMinY(selectedCellFrame);

CGFloat finalFrameY = CGRectGetMinY(selectedCellFrame);

if (menuIsAboveCell) {
finalFrameY += CGRectGetHeight(selectedCell.messageBubbleTopLabel.frame) + CGRectGetHeight(selectedCell.cellTopLabel.frame);
}
else {
finalFrameY += CGRectGetHeight(selectedCell.cellBottomLabel.frame);
}

CGRect finalFrame = CGRectMake(CGRectGetMinX(selectedCellFrame),
finalFrameY,
CGRectGetWidth(selectedCellFrame),
CGRectGetHeight(selectedCellFrame));

[menu setTargetRect:finalFrame inView:self.view];
[menu setTargetRect:selectedCellMessageBubbleFrame inView:self.view];
[menu setMenuVisible:YES animated:YES];

self.selectedIndexPathForMenu = nil;
Expand Down

0 comments on commit 3bfa3fd

Please sign in to comment.