UIMenuController sharedMenuController - пользовательский элемент меню для uicollectionview не отображается в ios 7
Я используюUIMenuItem
выполнить пользовательское действие вUICollectionView
клетка долгое нажатие. это прекрасно работало с iOS 6, но теперь я конвертирую свое приложение в iOS 7 и Xcode 5, и оно не работает. Пользовательский элемент не отображается.
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Unfavorite"
action:@selector(unFavorite:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:menuItem]];
[UIMenuController sharedMenuController].menuVisible = YES;
- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender;
{
//do not show default itens like copy, paste....
[self becomeFirstResponder];
return NO;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// The selector(s) should match your UIMenuItem selector
if (action == @selector(unFavorite:)) {
return YES;
}
return NO;
}
- (void)collectionView:(UICollectionView *)collectionView
performAction:(SEL)action
forItemAtIndexPath:(NSIndexPath *)indexPath
withSender:(id)sender {
}
- (BOOL)collectionView:(UICollectionView *)collectionView
shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
myIndexPath = indexPath;
return YES;
}