Skip to content

Instantly share code, notes, and snippets.

@piaoapiao
Created November 20, 2012 15:47
Show Gist options
  • Save piaoapiao/4118716 to your computer and use it in GitHub Desktop.
Save piaoapiao/4118716 to your computer and use it in GitHub Desktop.
Paste
-(void)paste:(id)sender
{
UIPasteboard *board = [UIPasteboard generalPasteboard];
NSArray *arr = board.strings;
NSLog(@"string:%@",[board.strings objectAtIndex:0]);
}
- (void)viewDidLoad
{
[super viewDidLoad];
UITextView *text = [[UITextView alloc] initWithFrame:CGRectMake(20, 20, 280, 80)];
text.text = @"sadfasdfasdfasd fasasdfasdfasd fasdf2131241234151 234234123421342423342";
[self.view addSubview:text];
UITextField *field = [[UITextField alloc] initWithFrame:CGRectMake(100, 120, 100, 30)];
field.borderStyle =UITextBorderStyleRoundedRect;
[self.view addSubview:field];
// [[UIMenuController sharedMenuController] ]
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 120, 100, 30)];
[btn setTitle:@"paste" forState:UIControlEventTouchUpInside];
[btn addTarget:self action:@selector(paste:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment