1. 程式人生 > >ios 複製字串到剪貼簿

ios 複製字串到剪貼簿

1.文字UILable設定可以互動

2.新增長按手勢

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(copyText:)];

[jobInfoText addGestureRecognizer:longPress];


3.響應長按手勢

- (void)copyText:(UILongPressGestureRecognizer *)gesture

{

if (gesture.state ==UIGestureRecognizerStateBegan

  {

UIPasteboard *pasteboard = [UIPasteboardgeneralPasteboard];

        [pasteboard setString:self.jobInfoText.text];

    }

}