I am adding UIViews to a superview in the following loop:
int xValue = 0 ;
int yValue = 10;
for (NSString *element in characters) {
UIView *newCharView = [[MyChar alloc] initWithFrame:CGRectMake(xValue,yValue,100,100)];
[(MyChar *)newCharView initLayers:element];
[[self view] addSubview:newCharView];
[newCharView autorelease];
if (xValue <= 240) {
xValue+=22;
} else {
xValue = 0;
yValue += 22;
}
}
MYChar contains a method which fires an animation. I want the method to be called sequentially in my loop with a delay of, say, 0.2 seconds. How can I achieve this? I tried delaying the animation itself but obviously just get the same delay in all the UIViews.
You could try using something like this:
You will have to experiment with that, as I don’t know what exactly you are trying to achieve.
EDIT:
Ouch, it’s definitely not a good way to go with such a large amount of views. You could try using one background loop to init all of them.
I would definitely have to think it over a lil more if I personally faced that problem, but here’s a simple suggestion, you will have to tune it to your needs and probably take care of its thread/memory management safety: