【问题标题】:how do I change auto-generated UIImageViews?如何更改自动生成的 UIImageViews?
【发布时间】:2010-08-03 08:51:07
【问题描述】:

我通过 for 循环自动创建 UIImageViews:

for (int i=0; i<anzahlzeilen; i++) {
   Anfanggrau = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Grauer-Balken.png"]];
   Anfanggrau.frame = CGRectMake(0, [heightofrow intValue]*i,[breitescroller2 intValue],[heightofrow intValue]); 

   [Inhalt1 addSubview:Anfanggrau];
   [Anfanggrau release];
};

现在,在一个事件之后,“breitescroller2”发生了变化,我需要更改 UIImageView 的所有宽度。通过第二次调用此代码,较旧的代码会留在那里,我会导致内存问题。有人有想法吗?是否可以给他们标签并通过removeFromSuperview 删除旧的?

非常感谢!

【问题讨论】:

    标签: objective-c cocoa-touch uikit uiimageview auto-generate


    【解决方案1】:
    for (id view in [Indalt1 subviews]) {
        if ([view isKindOfClass:[UIImageView class]]) {
            [view removeFromSuperview];
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 2013-03-31
      • 2020-11-07
      • 2017-08-21
      • 2012-05-06
      • 2013-10-16
      相关资源
      最近更新 更多