且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

swift,如何从UIImageView获取当前显示的图像文件名

更新时间:2021-07-14 08:32:21

您不能这样做.既不迅速也不客观-c.

You can't do this. Neither in swift nor objective-c.

要做的是存储要检索的数据.也就是说...将名称存储在某个地方,然后使用它来加载图像.并非如此.

The thing to do is to store the data you want to retrieve. That is... store the name somewhere and use that to load the image. Not the other way around.

因此,请创建类似于imageName的属性,然后使用该属性加载图像.

So create a property something like imageName and then use that to load the image.