Is there any way to copy text from a TextView that has User Interaction disabled to the clipboard via a UIButton?
What's the problem in just doing this in your IBOutlet for action?
Code:
if ([pasteboard containsPasteboardTypes: [NSArray arrayWithObject:@"public.utf8-plain-text"]])
NSLog(@"WE gots a string which is: %@", pasteboard.string);
What's the problem in just doing this in your IBOutlet for action?
Code:
if ([pasteboard containsPasteboardTypes: [NSArray arrayWithObject:@"public.utf8-plain-text"]])
NSLog(@"WE gots a string which is: %@", pasteboard.string);
That looks to be what I need but I'm having some issues with getting a value into the pasteboard.
Code:
- (IBAction)btnCopyClicked:(id)sender {
pasteboard.string = @"Test";
if ([pasteboard containsPasteboardTypes: [NSArray arrayWithObject:@"public.utf8-plain-text"]]) {
NSLog(@"WE gots a string which is: %@", pasteboard.string);
}
}
Make sure that you have the following in the property of interface
Code:
UIPasteboard *pastboard;
and the following in your init (or viewdidload) method
Code:
pasteboard = [UIPasteboard generalPasteboard];
The above is important to initialize the pastboard.
Also, you must keep in mind that the pastboard will only get populated (based on what I know) ONLY from the copy, cut actions call out by the "OS". NOT by your function... So the process is:
user selects text
OS shows the call out (cut, copy)
user does a copy/cut
OS puts the text into the pasteboard stack (i.e. UIPastboard generalPastboard)
Then you can grab it from the general pastboard via pastboard.string
Is there any way to use the UIPasteboard class and check for the device version so it works only in 3.0 and above?
I already did the check and stuff, the problem is that it won't compile for 2.2.1.