同时动画两个UIView子视图不起作用

ssh*_*h88 2 xcode core-animation uiviewcontroller uiview ios

由于某种原因,我无法两个动画两个子视图postion.我写了以下内容

[self addChildViewController:self.photosViewController];
[self.photosViewController.view setFrame:CGRectMake(0, -self.view.frame.size.height,    self.view.frame.size.width, self.view.frame.size.height)];

[self.view addSubview:self.photosViewController.view];

[UIView animateWithDuration:1 delay:0
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^{

                         [self.stepsView setFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
                         [self.photosViewController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
                     }
                     completion:^(BOOL finished) {
                         if (finished) {

                             button.tag = 0;
                         }
                     }];
Run Code Online (Sandbox Code Playgroud)

self.stepsView是一个IBOutlet UIView并且self.photosViewController.view是已添加到视图的子视图控制器视图.

目前的代码只有self.PhotosViewController.view动画.但是,如果我注释掉我添加子视图控制器视图的行,subview那么self.stepsView动画正确.

即使我在调用此方法之前添加了子视图控制器及其视图,也会发生相同的错误.

需要帮助,因为我用另一个应用程序跑了几个月,不得不做一个肮脏的黑客来绕过它,现在想解决这个问题.

谢谢

Mun*_*ndi 5

在上观看动画节查看编程指南有一个具体提到的如何动画子视图.

基本上,你应该使用transitionWithView:duration:options:animations:completion:而不是animateWithDuration:delay:options:animations:completion:.