Objective c 如何在UICollectionView中更改编辑菜单?
我使用UICollectionView制作了一个小应用程序。 我只想在点击“长按”时更改编辑菜单,但无法更改 例如,将“剪切”改为“删除”Objective c 如何在UICollectionView中更改编辑菜单?,objective-c,cocoa-touch,ios6,uicollectionview,Objective C,Cocoa Touch,Ios6,Uicollectionview,我使用UICollectionView制作了一个小应用程序。 我只想在点击“长按”时更改编辑菜单,但无法更改 例如,将“剪切”改为“删除” 我按照下面的代码实现我的操作表。 但这不是我想要的,因为我必须在UICollectionView范围之外实现ActionSheetDelegate 我想在performAction方法中实现操作表,以便于控制。 有什么建议吗?谢谢大家! - (BOOL)collectionView:(QSCollectionView *)collectionView sh
我按照下面的代码实现我的操作表。 但这不是我想要的,因为我必须在UICollectionView范围之外实现ActionSheetDelegate 我想在
performAction
方法中实现操作表,以便于控制。有什么建议吗?谢谢大家!
- (BOOL)collectionView:(QSCollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath{
QSCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UIActionSheet *deleteButton = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:@"Remove: %@",[collectionView.collectionData objectAtIndex:indexPath.row]] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"OK" otherButtonTitles: nil];
[deleteButton showFromRect:CGRectMake(0, 57, 57, 20) inView:cell animated:NO];
return YES;
}
-(BOOL)collectionView:(QSCollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender{
return YES;
}
-(void)collectionView:(QSCollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender{
}
//ActionSheet
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
switch (buttonIndex) {
case 0:
NSLog(@"Delete");
break;
default:
break;
}
}
您应该实现自己的
UIActionSheet
类,并在longPress
操作发生时显示
这是和。虽然这在理论上可以回答问题,但在这里包括答案的基本部分,并提供链接供参考。如果我希望它像菜单而不是行动表,该怎么办?