UIPopoverViewController presentModalViewController 动画

Posted

技术标签:

【中文标题】UIPopoverViewController presentModalViewController 动画【英文标题】:UIPopoverViewController presentModalViewController animation 【发布时间】:2011-07-19 12:59:25 【问题描述】:

我正在开发一款 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 没有任何视图属性,因此我无法向其添加任何动画。如果我在弹出框内的视图控制器中添加动画,则弹出框会停留在其位置,并且其中的视图会进行动画处理,看起来不太好。

【问题讨论】:

【参考方案1】:

做不到,popover 不是视图控制器。

【讨论】:

以上是关于UIPopoverViewController presentModalViewController 动画的主要内容,如果未能解决你的问题,请参考以下文章

UIPopoverViewController 添加子视图很慢

禁用 UIPopoverViewController 内容视图上的阴影

UIPopoverViewController presentModalViewController 动画

如何将导航栏和标签栏设置为通过 UIPopoverViewController 的视图?

uiactivityindicatorview 在 uipopoverviewcontroller iphone 中不起作用

在呈现 UIPopoverViewController 时,如何使除 sourceView 之外的所有内容变暗?