您的位置:首页 > 移动开发 > IOS开发

iOS collection长按编辑功能

2015-10-16 16:07 387 查看
//长按是否出现编辑菜单(Cut Copy Paste)

- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath

{

return YES;

}

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender

{

NSString * selName=NSStringFromSelector(action);

//菜单中只会出现copy

if ([selName isEqualToString:@"copy:"]) {

return YES;

}

return NO;

}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender

{

//可以执行一些拷贝粘贴等操作

//详细的东西请看 UIPasteboard

//点击Copy要执行的方法

NSString * selName=NSStringFromSelector(action);

NSLog(@"%@",selName);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: