(IOS)长按复制功能

- (void)viewDidLoad

{

    [self.view addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:selfaction:@selector(pasteBoard:)]];

}

- (void)pasteBoard:(UILongPressGestureRecognizer*)longPress {

    if (longPress.state == UIGestureRecognizerStateBegan) {

        UIPasteboard*pasteboard = [UIPasteboardgeneralPasteboard];

        pasteboard.string=@"需要复制的文本";

    }

}

你可能感兴趣的:((IOS)长按复制功能)