如何在我的自定义 TableviewCell 中访问 ImageView 而无需创建其出口

How to access an ImageView in my Custom TableviewCell without making its outlet

我的 TableView Cell xib 中有一个 ImageView,我想在我的 viewController 中访问这个图像视图,但我不想创建 imageView 的出口,即在我的单元格中,因为我可以访问我的ViewController 中的单元格,那么我怎样才能访问图像视图。
提前致谢

我假设您想要在代码的 cellForRowAt 函数中找到 imageView,以便您可以设置它的图像。

在cell的设计中,给UIImageView一个tag(eg. 7)。然后在您检索单元格后的代码中,您可以使用以下方法找到 imageView:

let imageView = cell.viewWithTag(7) as! UIImageView