【问题标题】:Unable to show UICollectionView menu in iOS8无法在 iOS8 中显示 UICollectionView 菜单
【发布时间】:2014-09-08 18:58:31
【问题描述】:

我正在尝试让 UIMenu 出现在集合视图中。

我已经设置了我的菜单

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]];

我已经在我的 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

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

提前致谢

【问题讨论】:

    标签: ios uicollectionview ios8 uimenucontroller


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-12-27
      • 2013-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-11
      • 1970-01-01
      • 2022-09-28
      相关资源
      最近更新 更多