什么是iPhone OS 4.0中基于块的动画方法?

问题描述:

我正在尝试使用iPhone OS 4.0(iOS4?)SDK实现游戏。在以前版本的SDK中,我一直在使用[UIView beginAnimations:context:]和[UIView commitAnimations]来创建一些动画。但是,当我查看4.0中函数的文档时,我看到了这个注释。

I am trying to implement a game using the iPhone OS 4.0 (iOS4?) SDK. In the previous versions of the SDK, I've been using the [UIView beginAnimations:context:] and [UIView commitAnimations] to create some animations. However, when I look at the documentation of the functions in 4.0, I see this comment.


不鼓励在$ b中使用此方法$ b iPhone OS 4.0及更高版本。你应该
使用基于块的动画方法
代替。

Use of this method is discouraged in iPhone OS 4.0 and later. You should use the block-based animation methods instead.

你可以在这里找到它:
http://developer.apple.com/iphone/library/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/clm/UIView/commitAnimations

You can find it here: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/clm/UIView/commitAnimations

我的问题是,iPhone OS 4.0中基于块的动画是什么?我虽然使用了beginAnimations:context:和commitAnimations函数来创建动画块..

My question is, what are block-based animations in iPhone OS 4.0? I though that the beginAnimations:context: and commitAnimations functions were used to create animation blocks..

如果您按照该链接进行操作向上滚动一下,你会看到ios4的新动画方法。

If you follow that link and scroll up a bit, you will see animate methods new to ios4.

animateWithDuration:animations:
animateWithDuration:animations:completion:
animateWithDuration:delay:options:animations:completion:

还有一些相关的过渡方法。对于其中的每一个,动画参数都是 block对象

There are also some related transition methods. For each of these, the animations argument is a block object:


动画

包含
的块对象提交的更改观点。
这是您以编程方式
更改视图层次结构中视图的
的任何可动画属性的位置。这个
块没有参数,也没有
的返回值。此参数不能
为NULL。

animations
A block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value. This parameter must not be NULL.

阻止对象并发编程