I subclasses UILabel to create a copiable label with this project. UILabel clipboard
This is the code it has:
- (void) copy: (id) sender
{
NSLog(@"Copy handler, label: “%@”.", self.text);
}
- (BOOL) canPerformAction: (SEL) action withSender: (id) sender
{
return (action == @selector(copy:));
}
- (void) handleTap: (UIGestureRecognizer*) recognizer
{
[self becomeFirstResponder];
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setTargetRect:self.frame inView:self.superview];
[menu setMenuVisible:YES animated:YES];
}
- (BOOL) canBecomeFirstResponder
{
return YES;
}
And the NSLog logs exactly the content I want to copy inside the label, however, the content is not copied to the clipboard.
Any idea?
And how to copy image?