2012-04-06 170 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