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

UICollectionView canPerformAction / shouldShowMenuForItemAtIndexPath #458

Closed
ghazel opened this issue Aug 27, 2014 · 6 comments
Closed

UICollectionView canPerformAction / shouldShowMenuForItemAtIndexPath #458

ghazel opened this issue Aug 27, 2014 · 6 comments
Milestone

Comments

@ghazel
Copy link
Contributor

ghazel commented Aug 27, 2014

Similar to #393, I would like to add menu items to some cells and disable the menu for others. It seems like the UICollectionView has some great functions for this (collectionView:canPerformAction:forItemAtIndexPath:withSender: collectionView:shouldShowMenuForItemAtIndexPath: etc) but JSQMessagesViewController doesn't use them.

Does it make sense to modify JSQMessagesCollectionViewCell to delegate to the collection view's delegate for menu handling?

@jessesquires jessesquires added this to the Release 6.0 milestone Aug 31, 2014
@jessesquires
Copy link
Owner

@ghazel - yes this would be preferable.

the reason it is the way it is now is because using these methods on JSQMessagesViewController displays the menu above the cell, which sometimes means above the timestamp label, so it looks kind of weird (since it isn't displayed about the message bubble).

awhile back i tried to implement the collectionView methods instead, and then adjust the frame of the menu, but had no luck.

@jessesquires
Copy link
Owner

Here's an attempt to move the UIMenuController handling from the collectionViewCell to the collectionView. You can see that it gets pretty ugly rather quickly, trying to find which cell was selected and then the correct frame for the bubble view.

8c9201e

@ghazel
Copy link
Contributor Author

ghazel commented Aug 31, 2014

Wow, that does seem like more work than I expected.

Why not handle the menu in the cell, but dispatch actions and canPerform to the collection?

@jessesquires
Copy link
Owner

@ghazel - yeah it makes me 😢 - the real problem is that when the menuWillShow notification is called, [self.collectionView indexPathsForSelectedItems] is empty. Otherwise, we could grab the currently selected cell, and set the menu's targetRect to the cell's messageBubbleImageView.

Why not handle the menu in the cell, but dispatch actions and canPerform to the collection?

That's an interesting idea. How exactly do you think this should work? You want to submit a PR? 😄

@ghazel
Copy link
Contributor Author

ghazel commented Sep 1, 2014

Here's what I was thinking: #463

@jessesquires
Copy link
Owner

so i just realized that the shouldShowMenuForItemAtIndexPath: and other delegate methods for the menu controller pass the indexPath.

so we can just save that indexPath and then this is super trivial. getting a fix together now.

i have no idea what i was thinking yesterday.

img

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants