【发布时间】: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