Copy feature in iOS using UIPboardboard

NSString *copyStringverse = [[NSString alloc] initWithFormat:@"%@",[textview.text]]; UIPasteboard *pb = [UIPasteboard generalPasteboard]; [pb setString:copyStringverse]; 

I use the code above to copy content to a textview , but I want to copy the contents to a table cell. How to do it. Thanks in advance.

+43
iphone uipasteboard
Jan 15 '12 at 12:20
source share
5 answers

Well, you didn’t specify exactly how your table view cell is set up, but if it's just text inside your table view, it can be as simple as:

 // provided you actually have your table view cell NSString *copyStringverse = yourSelectedOrClickedTableViewCell.textLabel.text; UIPasteboard *pb = [UIPasteboard generalPasteboard]; [pb setString:copyStringverse]; 
+71
Jan 15 '12 at 12:25
source share
— -
 [UIPasteboard generalPasteboard].string = @"Copy me!"; 
+23
Aug 07 '14 at 10:57 on
source share

For Swift 2.1 +:

 let cell = tableView.cellForRowAtIndexPath(indexPath) as! UITableViewCell // change this to your custom cell if you use one UIPasteboard.generalPasteboard().string = cell.textLabel.text 
+4
Feb 01 '16 at 10:30
source share

For Swift 3.x

 UIPasteboard.general.string = "String to copy" 
+3
Dec 03 '16 at 22:31
source share

For Swift2.2

 UIPasteboard.generalPasteboard().string = tableViewCell.textLabel.text 

Using this, you can directly set the value of UIPasteboard .

+1
Oct. 14 '16 at 12:34
source share



All Articles