OGeek|极客世界-中国程序员成长平台

标题: ios - 无法在 iOS8 中显示 UICollectionView 菜单 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:48
标题: ios - 无法在 iOS8 中显示 UICollectionView 菜单

我正在尝试让 UIMenu 出现在 Collection View 中。

我已经设置了我的菜单

UIMenuItem* deleteItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"Supprimer") actionselector(deleteShow];
UIMenuItem* archiveItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"ARCHIVE", @"Archiver") actionselector(archiveShow];
UIMenuItem* unarchiveItem = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"UNARCHIVE", @"Restaurer") actionselector(unArchiveShow];

[[UIMenuController sharedMenuController] setMenuItems[deleteItem,archiveItem,unarchiveItem]];

我已经在我的 Collection View Delegate 中实现了以下方法:

- (BOOL)collectionViewUICollectionView *)collectionView shouldShowMenuForItemAtIndexPathNSIndexPath *)indexPath
- (BOOL)collectionViewUICollectionView *)collectionView canPerformActionSEL)action forItemAtIndexPathNSIndexPath *)indexPath withSenderid)sender
- (void)collectionViewUICollectionView *)collectionView performActionSEL)action forItemAtIndexPathNSIndexPath *)indexPath withSenderid)sender

前两个总是返回 YES。 但是长按没有菜单显示。甚至不是标准的剪切/复制/粘贴菜单。 有没有人经历过这样的事情?

提前致谢



Best Answer-推荐答案


花了一些时间解决这个问题。发现如果在UICollectionViewCell的子类中不实现“deleteShow:”等方法,菜单项就不会显示出来。

关于ios - 无法在 iOS8 中显示 UICollectionView 菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25731251/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4