在ARC中的多个UIImageViews上的UIView动画 [英] UIView Animation on multiple UIImageViews in ARC

查看:158
本文介绍了在ARC中的多个UIImageViews上的UIView动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个动画,它会生成UIImageView然后缩小它(实际上是两个动画)。在整个应用程序中,这可能发生在几个不同的UIImageViews上。我找到了一种方法可以很好地工作,但它现在似乎与自动引用计数不兼容。这是我的代码:

I have an animation in my app that grows a UIImageView and then shrinks it (really two animations). Throughout the app this may happen on several different UIImageViews. I found a way to do this that worked really well, but it now doesn't seem to be compatible with Automatic Reference Counting. Here is my code:

[UIView beginAnimations:@"growImage" context:imageName];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
imageName.transform = CGAffineTransformMakeScale(1.2, 1.2);
[UIView commitAnimations];

然后:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(UIImageView *)context {
    if (animationID == @"growImage") {
    [UIView beginAnimations:@"shrinkImage" context:context];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    [UIView setAnimationDelegate:self];
    context.transform = CGAffineTransformMakeScale(0.01, 0.01);
    [UIView commitAnimations];
    }
}

这很完美,我很满意,直到我尝试将我的项目转换为ARC。我现在得到错误在这些行中我不允许使用ARC禁止将Objective-C指针隐式转换为'void *',其中我尝试将UIImageView作为动画的上下文传递:

This worked perfectly and I was very happy with it, until I tried converting my project to ARC. I now get the error "Implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC" on these lines in which I try to pass a UIImageView as the context for the animation:

[UIView beginAnimations:@"growImage" context:imageName];
[UIView beginAnimations:@"shrinkImage" context:context];

有没有人知道我可以提醒我想要它的UIImageView的animationDidStop函数的另一种方式采取行动是否符合ARC?

Does anybody know of another way that I can alert the "animationDidStop" function of which UIImageView I want it to act on that would be compliant with ARC?

非常感谢提前!

推荐答案

你可以这样做:

[UIView beginAnimations:@"growImage"
                context:(__bridge void*)imageName];
imageName.transform = ...
[UIView commitAnimations];

这篇关于在ARC中的多个UIImageViews上的UIView动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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