gpt4 book ai didi

iphone - 无法在动画 block 中的循环上设置动画

转载 作者:行者123 更新时间:2023-12-01 16:56:52 26 4
gpt4 key购买 nike

我有以下动画 block :

[UIView animateWithDuration:3.0 animations:^{
NSLog(@"INDEX %d", index);

[self.visibleViewControllers_ enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
UIViewController *viewController = (UIViewController *)obj;
if (viewController.view.tag != index){
if (viewController.view.tag < index){
NSLog(@"LOWER VIEW WITH TAG %d", viewController.view.tag);
[viewController.view setFrameY:self.contentOffset.y - viewController.view.frameHeight];
} else if (viewController.view.tag > index){
NSLog(@"UPPER VIEW WITH TAG %d", viewController.view.tag);
[viewController.view setFrameY:600];
} else {
[viewController.view setFrame:CGRectMake(0, self.contentOffset.y, selectedView.frameWidth, 460)];
}
}
}];
//[selectedView setFrame:CGRectMake(0, self.contentOffset.y, selectedView.frameWidth, 460)];
}completion:^(BOOL finished){
[self.visibleViewControllers_ enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
UIViewController *viewController = (UIViewController *)obj;
NSLog(@"VIEW CONTROLLER Y IS %f AT INDEX %d", viewController.view.frameY, viewController.view.tag);
}];

}];

基本上它是一个 View Controller 字典,它是我想要动画的 View ,但奇怪的是它只执行一个动画。不是全部。为什么是这样?是否可以在动画 block 内进行枚举?

最佳答案

枚举您的 View 并在您的枚举中为它们设置动画

[self.visibleViewControllers_ enumerateKeysAndObjectsUsingBlock:^
[UIView animation.....

你做了一个动画并枚举了这个动画中的所有 View 。把它转过来

关于iphone - 无法在动画 block 中的循环上设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10916709/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com