Skip to content

Instantly share code, notes, and snippets.

@antongaenko
Created October 27, 2014 15:16
Show Gist options
  • Save antongaenko/2aabcf2696c1143619d6 to your computer and use it in GitHub Desktop.
Save antongaenko/2aabcf2696c1143619d6 to your computer and use it in GitHub Desktop.
Allow copy action for chat messages
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
return action == @selector(copy:);
}
- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
FLMessage* msg = self.fetchController.fetchedObjects[indexPath.row];
UIPasteboard *pasteBoard = [UIPasteboard pasteboardWithName:UIPasteboardNameGeneral create:NO];
pasteBoard.persistent = YES;
pasteBoard.string = msg.text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment