动画的UIImageView在停止的UITableView(UIImageView Animatio

2019-10-19 18:02发布

我有一个UITableViewCell内一个UIImageView。 该动画的UIImageView。 对于一些奇怪的原因,当电池超出来看,动画停止。 该的UIImageView是永远不会再次初始化和的UIImageView从未明确告知 - (无效)stopAnimating; 所以我不知道为什么它停止。

这里是我的cellForRowAtIndexPath的有趣的部分:。 尽你所能

cell = (BOAudioCell *)[tableView dequeueReusableCellWithIdentifier:AudioCellIdentifier];
if (!cell) {
    cell = [[[BOAudioCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AudioCellIdentifier] autorelease];
    BOPlayControl *playControl = [(BOAudioCell *)cell playControl];
    [[playControl playbackButton] addTarget:self action:@selector(playbackButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
}

int index = [indexPath row];

BOModel *model = [models objectAtIndex:index];
[[(BOAudioCell *)cell titleLabel] setText:[model title]];
[[(BOAudioCell *)cell favoriteButton] addTarget:self   action:@selector(favoriteButtonTapped:) forControlEvents:UIControlEventTouchUpInside];

正如你所知道的,我没有设置相应的动画开始点小区,因为没有一个内置在一个UIImageView方式。

Answer 1:

你应该已经暴露了的UIImageView你的细胞,并开​​始cellForRowAtIndexPath方法中的动画或做的UITableViewCell的prepareForReuse方法的重写,并开始在该方法的动画。

prepareForReuse被称为每次你的可重复使用的电池是由可重复使用的队列中离开的时间。 只是要注意,如果你使用这个,不要忘记调用父类的实现。



Answer 2:

当细胞熄灭屏,它将被释放,并且子视图(图像视图)将被释放,以及,使要停止的动画。

保持-retain该图像视-ed实例某处避免这种情况。



Answer 3:

我写了一个解决方法。 我只是使用的NSTimer手动协调动画的UIImageView的。 它的伟大工程。



文章来源: UIImageView Animation Stopping in UITableView