为什么setAnimationDidStopSelector气馁? [英] why is setAnimationDidStopSelector discouraged?

查看:96
本文介绍了为什么setAnimationDidStopSelector气馁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在setAnimationDidStopSelector上的apple文档中看到以下内容:

i saw the following in apples documentation on setAnimationDidStopSelector:

在iOS 4.0及更高版本中不鼓励使用此方法。如果您使用的是基于块的动画方法,您可以直接在您的块中包含您的委托的结束代码。

"Use of this method is discouraged in iOS 4.0 and later. If you are using the block-based animation methods, you can include your delegate’s end code directly inside your block."

我尝试在动画块内添加动画停止委托中的内容,但是动画与我使用setAnimationDidStopSelector时的动画效果不一样。

I tried adding what I was going to put inside the animation stop delegate inside the animation block, but the animation doesn't look the same as when i used setAnimationDidStopSelector.

阻止使用setAnimationDidStopSelector的原因是什么?

What is the reason for discouraging the use of setAnimationDidStopSelector?

推荐答案

有许多API在Cocoa Touch中被弃用。该框架相当年轻,Apple仍在调整底层代码。当它在你的问题中被表达时,它可能意味着我们将尽一切努力使块动画完美,setAnimationDidStopSelector将在未来的某个时候被弃用 - 帮自己一个忙,现在停止使用它。

There are lots of APIs that get deprecated in Cocoa Touch. The framework is fairly young and Apple is still tweaking the underlying code. When it is phrased as in your question it probably means "we are going to put all our effort into making block animations perfect, setAnimationDidStopSelector will at some time in the future be deprecated - do yourself a favor and stop using it now".

你的动画表现不同听起来很奇怪吗?你这样做了吗?

It sounds weird that your animation behaves different? Have you done it like this?

    [UIView animateWithDuration:1.0
        delay: 0.0
        options: UIViewAnimationOptionCurveEaseIn
        animations:^{
             aView.alpha = 0.0;
        }
        completion:^(BOOL finished){
            // Do your setAnimationDidStopSelector stuff here!
        }];

这篇关于为什么setAnimationDidStopSelector气馁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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