Reputation: 81
I'm trying to make a UIMenu appear in a collection view.
I've setup my menu
UIMenuItem* deleteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"Supprimer") action:@selector(deleteShow:)];
UIMenuItem* archiveItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"ARCHIVE", @"Archiver") action:@selector(archiveShow:)];
UIMenuItem* unarchiveItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"UNARCHIVE", @"Restaurer") action:@selector(unArchiveShow:)];
[[UIMenuController sharedMenuController] setMenuItems:@[deleteItem,archiveItem,unarchiveItem]];
And I've implemented the following methods in my Collection View Delegate :
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath
- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
The first two always returns YES. But no menu is showing on long press. Not even the standard cut/copy/paste menu. Anyone experienced something like this?
Thanks in advance
Upvotes: 3
Views: 805
Reputation: 3473
Spent some time for this problem. Found that if you do not implement "deleteShow:" and etc. method in the UICollectionViewCell's subclass, the menu item would not show up.
Upvotes: 3