我正在创建一个应用程序,以便在我在iOS设备上复制内容时保存复制的项目。
无论如何我可以创建一个活动,以便我可以随时从iOS设备上的任何应用程序复制内容,将其保存到我的应用程序中吗?
我希望它能随时复制文本,以便将其粘贴到我的应用文本框中。
答案 0 :(得分:9)
- (void)copy {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"String";
}
- (void)paste {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *string = pasteboard.string;
NSLog(@"%@",string");
}
请参阅此链接UIPasteBoard
答案 1 :(得分:0)
看看UIResponderStandardEditActions非正式协议:
关键是确保您的视图控制器可以成为第一响应者,然后实现以下方法:
- (void)copy:(id)sender;
- (void)paste:(id)sender;
答案 2 :(得分:-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];