从uiimageview获取图像名称 [英] Getting image name from uiimageview

查看:105
本文介绍了从uiimageview获取图像名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过触摸该图像内部来获取特定的图像名称。任何人都可以给我样本代码吗?

I want to get the particular image name by touching inside of that image. Can any one give me the sample code for that?

推荐答案

Nick Weaver是对的。不过还有一种方法可以做到。

Nick Weaver is correct. There is still a way to do it, though.

创建一个包含图像名称的数组。设置每个 UIImageView 的tag属性,使其对应于数组中的名称。然后,通过tag属性访问数组。

Create an array with the names of the images. Set the tag property of each UIImageView so it corresponds to the names in the array. Then, access the array via the tag property.

NSArray *nameArray = [NSArray arrayWithObjects:@"image1", @"image2", nil];

//touch happened

NSString *imageName = [nameArray objectAtIndex:imageView.tag];

另一种方法是创建 UIImageView 子类。

这篇关于从uiimageview获取图像名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆