2013-03-07 40 views
0

我有40个UIView瓷砖对象在屏幕上。然后在视图控制器中,我有例程使用transitionFromView消息来翻转这些图块。如果我在循环中立即翻转它们,在模拟器上它看起来很平滑,但在iPhone上它正在努力翻转它们。这是因为iPhone CPU/GPU速度较慢,无法同时处理这么多转换。所以我想要做的是某种链式转换,最终在任何时候都会转换5-10。现在每翻转0.4秒。什么是最简单的方法来做到这一点?如何进行链式转换?

+0

启动顺序不应该有这个问题。一旦您要求提供40个翻转视图的动画,就应该毫无困难地执行。也许你应该向我们展示你的代码?也许你做错了。另外,请用乐器试用;它会告诉你问题到底在哪里。 – matt 2013-03-07 00:10:29

+0

那么,代码非常大,修剪它并不容易。这在iPhone 4上也不是问题。但我也必须支持3GS。所以我真的需要链接这些动画,它也会带来一些好的效果,而不是一次翻转。 – Pablo 2013-03-07 00:17:29

+0

你可以显示你正在做转换的循环吗? – 2013-03-07 01:32:37

回答

0

我可能采取的方法就是让动画一个接一个地stag stag。

只是保持与所有你要动画意见NSArray *views,并与[self transformViewAtIndex:[NSNumber numberWithInt:0]];

- (void)transformViewAtIndex:(NSNumber *)index { 
    // Make sure we're not out of bounds 
    if ([index intValue] >= [views count]) return; 

    // Get the view we want to work on 
    UIView *view = [views objectAtIndex:[index intValue]]; 

    // Perform the animation 
    [UIView animateWithDuration:0.4 animations:^{ // Whatever duration you want 
     // ... This is where your actual transformation code goes 
    }]; 

    // Schedule the next animation 
    NSNumber *newIndex = [NSNumber numberWithInt:[index intValue] + 1]; 
    [self performSelector:@selector(transformViewAtIndex:) withObject:newIndex afterDelay:0.2]; // Set delay to a number that is effective 
} 
0

UIView transition...动画方法占用completion块。有你的链条。排列您的块并将它们设置为链中连续调用的完成块。

或构建分组动画。