gpt4 book ai didi

ios - [UIViewAnimationStateanimationDidStop :finished:]: message sent to deallocated instance

转载 作者:行者123 更新时间:2023-11-29 04:45:06 25 4
gpt4 key购买 nike

我有一个 UIImageView 的子类,它会定期刷新自己以显示不同的图像。我使用下面的代码没有任何问题:

UIImage *cachedImage = [[SDImageCache sharedImageCache] imageFromKey:blobKey];
if(cachedImage==nil) {
NSData *imageData=[NSData dataWithContentsOfURL:url];
cachedImage = [UIImage imageWithData:imageData];
[[SDImageCache sharedImageCache] storeImage:cachedImage imageData:imageData forKey:blobKey toDisk:YES];
}
self.image=cachedImage;
CATransition *transition = [CATransition animation];
transition.duration = 2.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.layer addAnimation:transition forKey:nil];

问题是当我决定使用 Apple 建议的 iOS 4.0+ 的“ block ”式动画而不是上面的代码时:

[UIView transitionWithView:self duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
self.image=cachedImage;
} completion:^(BOOL finished) {
// do something..
}];

应用新代码后,我收到错误消息:“消息发送到已释放的实例”。 (我有 iOS 5.1 SDK 并启用了 ARC。)我应该学习 block 编程的任何方面吗?

最佳答案

在我的例子中,在动画 block 工作正常后将图像属性设置为零。

关于ios - [UIViewAnimationStateanimationDidStop :finished:]: message sent to deallocated instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9773888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com