我下面的循环中添加UIViews到上海华:如何发送时间延迟的消息,一个UIView上的计时器
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包含触发动画的方法。我希望在我的循环中按顺序调用该方法,延迟时间例如为0.2秒。我怎样才能做到这一点?我尝试延迟动画本身,但显然只是在所有UIViews中获得相同的延迟。
谢谢你的工作。在模拟器中性能很好,但在设备(iPhone4)上可怕。我不是说它的代码,但如果我添加140个UIViews,每个包含30层,有没有更好的方法来做到这一点? – codecowboy 2010-09-04 04:57:35
我刚刚编辑了我的回复,这应该会提高很多。 – Mayjak 2010-09-04 19:39:06