Iphone 是否仅在UIButton动画完成后更新标签?
我在iAction(按钮按下)方法中使用了该代码:Iphone 是否仅在UIButton动画完成后更新标签?,iphone,objective-c,animation,uibutton,Iphone,Objective C,Animation,Uibutton,我在iAction(按钮按下)方法中使用了该代码: 还有一个标签,我只想在完成后更新。我想知道是否有一个简单的例子,任何人都可以提供给我,让标签只更新时,这是完成,而不是当方法完成。我知道你不能使用“@selector(animationDidStop:finished:context:”,因为苹果不喜欢它。有人帮忙吗?请,谢谢 为什么不直接使用UIView动画块 [UIView animateWithDuration:0.75 delay:0 options:0 animations:^{
还有一个标签,我只想在完成后更新。我想知道是否有一个简单的例子,任何人都可以提供给我,让标签只更新时,这是完成,而不是当方法完成。我知道你不能使用“@selector(animationDidStop:finished:context:”,因为苹果不喜欢它。有人帮忙吗?请,谢谢 为什么不直接使用UIView动画块
[UIView animateWithDuration:0.75 delay:0 options:0 animations:^{
theButton.transform = CGAffineTransformMakeRotation((720*M_PI)/180);
} completion:^{
theLabel.text = @"Whatever";
}];
如果需要4.x版本之前的兼容性,请使用旧表单,并使用UIView类方法+setAnimationDidStopSelector:
,如下所示:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDidStopSelector:@selector(someMethodInWhichYouSetTheLabelText)];
theButton.transform = CGAffineTransformMakeRotation((720*M_PI)/180);
[UIView commitAnimations];
我知道你不能用
“@selector(animationDidStop:finished:context:)”
事实上,你可以给它取另一个名字,这样它就不会和苹果的内部方法冲突
关于你的问题:
委派
指定接收器的
委托对象
animationDidStop:已完成:
什么时候叫
动画完成其活动
从对象中删除持续时间或时间
它是附在
我去尝试了底层代码,因为我确实希望它是4x之前的。不幸的是,我不熟悉这一点,我在CGAffineTransformMakeRotation行上遇到了一个错误:“请求在非结构或联合中的成员‘转换’。”。。。。对我这样的白痴有什么想法吗?顺便说一句。。我唯一能让@selector在多个按钮上工作并正确使用setAnimationDidStop@selectorwas将使用行[UIView setAnimationDelegate:self]而不是[UIView commitAnimations]
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDidStopSelector:@selector(someMethodInWhichYouSetTheLabelText)];
theButton.transform = CGAffineTransformMakeRotation((720*M_PI)/180);
[UIView commitAnimations];