0

我正在开发一个 iPad 应用程序。我有一个视图控制器,我想在弹出框控制器中显示它。但我也想在 modalview 中呈现它时向弹出框添加自定义动画。如何在呈现和关闭模态视图时向弹出框添加自定义动画?

下面是我的代码:

Myviewcontroller *myViewController = [[Myviewcontroller alloc] initWithNibName:@"Myviewcontroller" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc] initWithRootViewController:myViewController];
myViewController.contentSizeForViewInPopover=CGSizeMake(900, 600);
UIPopoverViewController popOVer = [[UIPopoverController alloc]
                initWithContentViewController:navController];
 [popover presentPopoverFromRect:CGRectMake(37, 90, 950, 560) inView:self.view permittedArrowDirections:0 animated:NO];

我要添加到上面的 popoverViewController 的动画是:

CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * 3]; // 3 is the number of 360 degree rotations

rotationAnimation.duration = 1.0f;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.fromValue = [NSNumber numberWithFloat:0.0];
scaleAnimation.toValue = [NSNumber numberWithFloat:1.0];
scaleAnimation.duration = 1.0f;
scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.duration = 1.0f;
[animationGroup setAnimations:[NSArray arrayWithObjects:rotationAnimation, scaleAnimation, nil]];

现在我的问题是如何将此动画添加到 popOverViewController 本身。由于 Popover 没有任何视图属性,因此我无法向其添加任何动画。如果我在弹出框内的视图控制器中添加动画,那么弹出框会停留在它的位置,并且它里面的视图动画看起来不太好。

4

1 回答 1

0

做不到,弹出框不是视图控制器。

于 2011-07-19T13:52:36.427 回答