如何更改自动生成的UIImageViews?

时间:2010-08-03 08:51:07

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

我通过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为他们提供标签并删除较旧的标签吗?

非常感谢!

1 个答案:

答案 0 :(得分:0)

for (id view in [Indalt1 subviews]) {
    if ([view isKindOfClass:[UIImageView class]]) {
        [view removeFromSuperview];
    }
}