Ios5 动画到情节提要

Ios5 动画到情节提要,ios5,Ios5,我有这个密码 UIImageView *sunrays = (UIImageView *)[self.view viewWithTag:1]; UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,sunrays.frame.size.width,sunrays.frame.size.height)]; [container setClipsToBounds:YES]; [container addSubview:sun

我有这个密码

UIImageView *sunrays = (UIImageView *)[self.view viewWithTag:1];
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,sunrays.frame.size.width,sunrays.frame.size.height)];
[container setClipsToBounds:YES];
[container addSubview:sunrays];
[sunrays setCenter:CGPointMake(container.bounds.size.width/2, container.bounds.size.height/2)];
[self.view addSubview:container];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:5];
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2.0];
rotationAnimation.duration = 10;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 10;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[sunrays.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
[UIView commitAnimations];
它在具有.xib文件的应用程序中正确运行

与情节提要完全相同的代码不会运行

我插入QuartzCore.framework和CoreGraphics.framework。
问题在哪里?有什么帮助吗?

您的代码在哪里?Soryboards创建的对象与XIB不同,因此,如果您的代码位于错误的方法中,则可能根本不会调用它。问题出在界面生成器中。我必须将ViewController的类更改为当前的ViewController类。