将UILabel的内容复制到剪贴板

时间:2013-11-15 00:53:26

标签: ios uilabel clipboard

我将UILabel子类化为此项目创建可复制标签。 UILabel clipboard

这是它的代码:

- (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;
}

NSLog会准确记录我要在标签内复制的内容,但是内容不会复制到剪贴板。

有什么想法吗?

如何复制图片?

0 个答案:

没有答案