【问题标题】:UIImageView Class problemUIImageView 类问题
【发布时间】:2010-11-30 23:54:05
【问题描述】:

我采用了 Imageview 类,并使用代码将图像添加到其中: TileImageView *tileImageView = [[Tile alloc] initWithImage:tileImage];

并像这样添加到视图中:[self.view insertSubview:tileImageView atIndex:0];

那么如何删除 Imageview 类并将新图像分配给该视图

【问题讨论】:

  • 甚至没有注意到这一点。非常可悲:提出了 22 个问题,其中大部分有答案,接受的答案为零
  • 哇,我以前从未见过!

标签: iphone objective-c


【解决方案1】:

UIView 类中有一个标签属性,您可以稍后使用它来检索视图。

titleImageView.tag = 1;

[self.view addSubview:titleImageView];

// later:

titleImageView = [self.view viewWithTag:1];
titleImage.view.image = otherImage;

或者您可以将图像视图的引用保存在实例变量中。

【讨论】:

    猜你喜欢
    • 2017-09-13
    • 1970-01-01
    • 2015-05-03
    • 2011-05-31
    • 2011-02-02
    • 2011-05-19
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    相关资源
    最近更新 更多