【问题标题】:Getting name of the image which is on the image view获取图像视图上的图像名称
【发布时间】:2011-06-26 14:36:19
【问题描述】:

有什么方法可以获取出现在我屏幕上的图像视图上的图像名称。请告诉我如何做到这一点。我已经搜索了很多,但仍然没有找到任何有用的东西。请帮忙。

【问题讨论】:

    标签: objective-c cocoa-touch ipad uiimageview uiimage


    【解决方案1】:

    您可以继承 UIImageView 并添加属性名称或标识符。

    @interface MyImageView : UIImageView{
        NSString *name;
    }
    @property (retain) NSString *name;
    -(id)initWithImage:(UIImage *)image andName:(NSString *)name;
    @end;
    
    
    @implementation MyImageView
    @synthesize name;
    -(id)initWithImage:(UIImage *)image andName:(NSString *)name
    {
        if(self = [super initWithImage:image]){
            self.name = name;
        }
        return self;
    }
    
    
    -(void)dealloc
    {
       self.name = nil;
       [super dealloc;]
    }
    

    【讨论】:

      【解决方案2】:

      你应该使用视图的tag属性来区分不同的imageView。

      【讨论】:

      • 但我想获得 hte 名称,使用标签我无法获得 taht
      • 但您可以使用标签跟踪您在其他地方保存的名称。
      • 但我也没有使用标签获取名称
      • 将名称存储在字典中,其中键是图像视图的标签。
      • 这就是我对 的意思,但是使用标签可以跟踪保存在其他地方的名称。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-02
      • 2017-05-08
      相关资源
      最近更新 更多