-1

我想从 访问我的视图对象UITableViewCell,但我不能。我无法转换我的单元格对象,因为我只有字符串UITableViewCell。例如“ClientTableViewCell”。

如何在不强制转换的情况下访问单元格中的视图和对象?我试图做如下:

let cell = (val as AnyObject).dequeueReusableCell(withIdentifier: "ClientTableViewCell") as! UITableViewCell

我可以得到一个像这样的单元格,但我无法到达内容。像这样尝试镜面反射:

let mirror = Mirror(reflecting: cell)

但是子标签和值是可选的

4

1 回答 1

0
guard let cell: ClientTableViewCell = tableView.dequeueReusableCell(withIdentifier: String(describing: ClientTableViewCell.self), for: indexPath) as? ClientTableViewCell else { return UITableViewCell() }

尝试这个

于 2020-05-14T21:14:00.463 回答