Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kwjohns

macrumors 6502a
Original poster
Jul 4, 2007
700
12
Is there any way to copy text from a TextView that has User Interaction disabled to the clipboard via a UIButton?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
In neither method are you setting pasteboard to anything. Where do you set it to a valid instance of UIPasteboard? Are you sure it's set?

Have you tried:
Code:
- (IBAction)btnCopyClicked:(id)sender { 
	UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
	[pasteboard setValue: @"Test" forPasteboardType: @"public.utf8-plain-text"];
	NSLog(@"Pasteboard: %@", pasteboard.string);
}
 

kwjohns

macrumors 6502a
Original poster
Jul 4, 2007
700
12
In neither method are you setting pasteboard to anything. Where do you set it to a valid instance of UIPasteboard? Are you sure it's set?

Have you tried:
Code:
- (IBAction)btnCopyClicked:(id)sender { 
	UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
	[pasteboard setValue: @"Test" forPasteboardType: @"public.utf8-plain-text"];
	NSLog(@"Pasteboard: %@", pasteboard.string);
}

I was missing the pasteboard = [UIPasteboard generalPasteboard]; which I had removed last night when troubleshooting it and forgot to add it back in. All is working now. Thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.