2012-04-06 168 views
1

我创建了一个应用程序来随时保存我复制的项目,我在iOS设备上复制了一些东西。iOS复制并粘贴

是否有无论如何我可以创建一个事件,以便我从我的iOS设备上的任何应用程序复制的东西,它将它保存到我的应用程序?

我希望它能在任何时候触发我复制文本,以便将其粘贴到我的应用程序文本框中。

+2

您是否试图编写任何代码? – theJollySin 2012-04-06 04:47:18

+0

我写了一些代码尝试并将它发送到我的数据库,但我努力创建一个事件,将触发并发送复制的文本到数据库,只要我点击复制 – MattF 2012-04-06 04:59:23

回答

9
- (void)copy { 

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 
    pasteboard.string = @"String"; 
} 


- (void)paste { 

     UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 
     NSString *string = pasteboard.string; 
     NSLog(@"%@",string"); 
} 

请参阅此链接UIPasteBoard

+0

downvoters告诉downvote作为评论的原因... – Aravindhan 2012-04-06 04:57:46

-1
UIPasteboard *pb = [UIPasteboard generalPasteboard]; 
    NSDictionary *CellData = [NSDictionary dictionaryWithDictionary:[ArrayName objectAtIndex:SelectedIndexPath.row]]; 
    NSString* strText = [(NSDictionary*)[(NSString*)[CellData objectForKey:@"Key"] JSONValue] objectForKey:@"english"]; 
    [pb setString:strText]; 
+1

请至少说出一句话,说明你的代码的功能和工作原理。没有上下文的情况下,只有代码的块很少使用。 – Addison 2016-11-18 07:34:19