设置animationDidStopSelector:对UIView的动画代表 [英] Setting animationDidStopSelector: on UIView's animation delegate

查看:155
本文介绍了设置animationDidStopSelector:对UIView的动画代表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得我一直在做这个错误在过去一年和我的iPhone开发经验半...我可以使用一些懂行的说明,请!

I think I've been doing this wrong for the past year and a half of my iPhone development experience... I could use some knowledgeable clarification please!

正如您可能会或可能不知道,UIView的性能可以很容易地使用 beginAnimations动画:forContext:方法,并以 commitAnimations 电话。

As you may or may not know, UIView properties can be animated quite easily using the beginAnimations:forContext: method, and wrap it up with a commitAnimations call.

您也可以当动画的某些部分会出现设置动画委托来执行操作,如启动,整理等。

You can also set an animation delegate to perform actions when certain parts of the animation occur, such as starting, finishing etc.

我已经使用的UIView在我的code动画很长一段时间,从未发生过任何严重的问题,但我刚刚碰到我必须错过的文档的部分。

I've been using UIView animations in my code for a long time and never had any serious problems, but I've just come across a section of the docs that I must have missed.

有关的UIView的 setAnimationDidStopSelector的文档:规定,任何选择传入此方法应该是这样的形式:

The documentation for UIView's setAnimationDidStopSelector: states that any selector passed into this method should be of the form:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;

我还没有做,在所有。我已经设定普通的老式 doThis 找时间做吧键入不带参数的选择。

I haven't been doing that at all. I've been setting plain old doThis and doThat type selectors that take no parameters.

是我一直在做是否可以接受?我应该重写我的所有code使用记录的形式?或者是,只是形式为方便起见,如果我需要知道被停止或需要前完成动画与否某个上下文特定的数据传递给方法?

Is what I've been doing acceptable? Should I rewrite all my code to use the documented form? Or is that form simply for convenience if I need to know whether or not the animation completed before being stopped or needed to pass some context specific data to the method?

推荐答案

这是可以接受的。

在装配水平,调用一个Objective-C的方法。

In assembly level, calling an Objective-C method

id something = [obj method:arg0 and:arg1 also:arg2 asWellAs:arg3];

看起来像(的的实际ARM code):

will look like (not actual ARM code):

load  r0      <- obj
load  r1      <- @selector(method:and:also:asWellAs:)
load  r2      <- arg0
load  r3      <- arg1
load  [sp, 0] <- arg2
load  [sp, 4] <- arg3
call          objc_msgSend
store r0      -> something

其中, objc_msgSend 将保留所有的寄存器中,找到 -method:和:也:asWellAs:,跳给它。在 -method:。... 编译器会将参数回寄存器相关联,即

where objc_msgSend will keep all the registers, find -method:and:also:asWellAs:, and jump to it. Within -method:… the compiler will associate the parameters back to the registers, i.e.

store r0        -> self
store r1        -> _cmd
store r2        -> param0
store r3        -> param1
store [sp, ?]   -> param2
store [sp, ?+4] -> param3
// rest of execution

现在发生什么,如果你的方法是唯一的 -doThis -doThat

Now what happen if your method is only -doThis or -doThat?

store r0        -> self
store r1        -> _cmd
// rest of execution

有将没有参数所以寄存器R2,R3和堆栈值可以自由地重写。在换句话说,编译器/运行时将忽略额外的参数

There will be no parameters so the registers r2, r3 and the stack values are free to override. In the other words, the compiler/runtime will simply ignore the extra parameters.

问题会,如果你占用太多的参数才会出现。

Problems will arise only if you take up too many parameters.

这篇关于设置animationDidStopSelector:对UIView的动画代表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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