我在这里保存到唯一粘贴板:
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"myPasteboard" create:YES];
[pasteboard setPersistent:YES];
//save to unique pasteboard
[pasteboard setString: [NSString stringWithFormat:@"%@",self.myTextFieldHere]];
试着在这里阅读:
UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithName:@"myPasteboard"];
_myTextFieldHere.text = [pasteSaved string];
对于我的本地变量pastesaved
到目前为止我尝试了什么
UIPasteboard *pasteSaved =[[UIPasteboard pasteboardTypes] containsObject:@"myPasteBoard"];
UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithName:@"myPasteboard"];
UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithUniqueName:@"myPasteboard"];
UIPasteboard *pasteSaved = [UIPasteboard: @"myPasteboard"];
UIPasteboard *pasteSaved = [UIPasteboard pasteboardWithUniqueName];
答案 0 :(得分:0)
创建独特的粘贴板后,使用addItems:
方法将项目粘贴到其中:
[pasteboard addItems:@[ @"my_string_for_pasting" ]];
或者,
[[UIPasteboard pasteboardWithUniqueName:@"myPasteboard"] addItems:@[ @"my_string_for_pasting"];
修改强>
从粘贴板中读取:
NSString *copiedString = [[UIPasteboard pasteboardWithUniqueName:@"myPasteboard"] valueForPasteboardType:kUTTypePlainText];
答案 1 :(得分:0)
修正了它
与使用应用专用粘贴板相比,如果您使用create YES or No
复制到粘贴板
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"myPasteboard" create:YES];
[pasteboard setPersistent:YES];
//save to unique pasteboard
[pasteboard setString: [NSString stringWithFormat:@"%@",self.myTextFieldHere]];
从粘贴板粘贴
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"ICPatEditionPasteboard" create:NO];
self.myTextFieldHere.text = [pasteboard string];