Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从所选单元格复制数据(Swift)_Ios_Swift_Xcode_Uitableview_Copy - Fatal编程技术网

Ios 从所选单元格复制数据(Swift)

Ios 从所选单元格复制数据(Swift),ios,swift,xcode,uitableview,copy,Ios,Swift,Xcode,Uitableview,Copy,我在UITableViewCellю中向左/向右滑动 如何使其能够从所选单元格复制数据 我试着用它: let cell = self.table.cellForRow(at: indexPath) UIPasteboard.general.string = cell?.detailTextLabel?.text 但应用程序崩溃了 替换: let cell = self.table.cellForRow(at: indexPath) UIPasteboard.general.string =

我在UITableViewCellю中向左/向右滑动

如何使其能够从所选单元格复制数据

我试着用它:

let cell = self.table.cellForRow(at: indexPath)
UIPasteboard.general.string = cell?.detailTextLabel?.text
但应用程序崩溃了

替换:

let cell = self.table.cellForRow(at: indexPath)
UIPasteboard.general.string = cell?.detailTextLabel?.text
与:

因为您正在
cellForRowAt
方法中使用
tableView
。因此,我用
tableView
替换了
table
,并在第二行用
textlab
替换了
detailtextlab


这应该是可行的。

您可以使用数据数组中的字符串,如下所示:

UIPasteboard.general.string = myData[indexPath.row]
除此之外:

let cell = self.table.cellForRow(at: indexPath)
UIPasteboard.general.string = cell?.detailTextLabel?.text

崩溃的原因是什么?@DharmeshKheni我不确定我是否复制了正确的一次终止应用程序,因为未捕获异常“NSInvalidArgumentException”,原因:“-[[u-UIConcretePasteboard setString:]:参数不是NSString[(null)]类型的对象”
UIPasteboard.general.string = myData[indexPath.row]
let cell = self.table.cellForRow(at: indexPath)
UIPasteboard.general.string = cell?.detailTextLabel?.text