我该怎么办的UIView animateWithDuration在viewDidLoad中? IOS 7 [英] how can i do UIView animateWithDuration in viewDidLoad? ios7

查看:195
本文介绍了我该怎么办的UIView animateWithDuration在viewDidLoad中? IOS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试这viewDidAppear,但我有延迟一秒钟=(我能做些什么?在viewDidLoad中工作?

   - (无效)viewDidAppear:动画(BOOL){
            fullRotation = [CABasicAnimation animationWithKeyPath:@transform.rotation];
            fullRotation.fromValue = [NSNumber的numberWithFloat:0];
            fullRotation.toValue = [NSNumber的numberWithFloat:((720 * M_PI)/ 360)];
            fullRotation.duration = 5;
            // fullRotation.repeatCount = 1e10f;
            [_propImaCirculoCompleto.layer addAnimation:fullRotation forKey:@360];
}


解决方案

您不应该做的 viewDidLoad中任何动画作为视图不会有上海华却又如此动画是无关紧要的。

在你的code样品的一点想法:


  • 您可以使用 viewDidAppear 只要你想要的每一个动画
    出现时间来看,不只是第一次是presented。


  • 动画块中使用的Core Animation是没有必要的。做一个或另一个。


建议

如果你想通过动画不同的视图控制器管理的视图的外观上,presenting控制器负责动画。有实现的iOS这取决于你的最低支持版本的一些方法。


  • 在iOS 5以上,你可以使用自定义容器控制器present子视图控制器定义动画。


  • 在搭载iOS 7,您可以使用'presentViewController:动画:完成,并指定一个自定义动画。然后,您可以设置 transitioningDelegate 属性,并有代表提供的过渡动画。


我没有准备好样品code为上述但是这会是什么样我在

I try this in viewDidAppear but i have a one second of delay =( what can i do? for work in viewDidLoad?

-(void)viewDidAppear:(BOOL)animated{


            fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
            fullRotation.fromValue = [NSNumber numberWithFloat:0];
            fullRotation.toValue = [NSNumber numberWithFloat:((720*M_PI)/360)];
            fullRotation.duration = 5;
            //  fullRotation.repeatCount = 1e10f;
            [_propImaCirculoCompleto.layer addAnimation:fullRotation forKey:@"360"];


}

解决方案

You shouldn't do any animation in viewDidLoad as the view won't have a superview yet so the animation is irrelevant.

A few thoughts on your code sample:

  • You can use viewDidAppear as long as you want the animation every time the view appears, not just the first time it is presented.

  • Using Core Animation within an animation block isn't necessary. Do one or the other.

Suggestions

If you are trying to animate the appearance of a view managed by a different view controller, the presenting controller is responsible for the animation. There are a few ways to implement this depending on your minimum supported version of iOS.

  • In iOS 5+ you can use a custom container controller to present a child view controller with a defined animation.

  • In iOS 7 you can use 'presentViewController:animated:completion' and specify a custom animation. You would then set the transitioningDelegate property and have the delegate provide the animator for the transition.

I don't have ready sample code for the above but that's what I would look at.

这篇关于我该怎么办的UIView animateWithDuration在viewDidLoad中? IOS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆