Hi together,
I have a custon view class which inherits from UIView. Inside the
- (void)drawRect:(CGRect)rect {}
I also generate some UILabels via
UILabel* aLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, length, height)];
[self insertSubview:aLabel atIndex:1];
[self.labelArray addObject:aLabel];
I put this view into an array container to remove all labels when drawRect is called again (last line)
At the beginning of my drawRect I remove all labels via
for (int i = 0; i < [self.labelArray count]; i++) {
[[self.labelArray objectAtIndex:i] removeFromSuperview];
}
This iseems not to work because the memory usage increases during runtime.
How to remove the labels without leaking memory? Is there a better way to solve this issue?