【问题标题】:continuous animation within UITableViewCellUITableViewCell 中的连续动画
【发布时间】:2010-10-06 13:43:03
【问题描述】:

我正在尝试将连续动画添加到我的 UITableViewCell-Subclass。 这是一个相当简单的图像淡入淡出(在 0.4 alpha 和 1.0 之间淡入), 到目前为止,我尝试过的内容如下:

-(void)animateRecordingIndicator{

    [UIView beginAnimations:@"RecordingIndicatorAnimation" context:nil];
    [UIView setAnimationDuration:0.3];

    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationFinished)];

    if (animatedImageView.alpha == 0.4) 
        animatedImageView.alpha = 1.0;
    else 
        animatedImageView.alpha = 0.4;    

    [UIView commitAnimations];
}

animationFinished里面的代码如下:

-(void)animationFinished{
    if (doShowAnimation) {
        [self performSelectorOnMainThread:@selector(animateRecordingIndicator) withObject:nil waitUntilDone:YES];
    }
}

我的期望现在应该很清楚了,但我得到的只是 Xcode 或多或少地永远加载 Stackframes 的崩溃:)

【问题讨论】:

  • 我回答之前的快速问题,iOS3 兼容性是强制性的吗?
  • 不是真的,我只是忽略了运行低于 4.1 或 4.0 的设备上的动画

标签: ios uitableview animation


【解决方案1】:

根据UIView class reference,您现在不鼓励使用 commitAnimations 方法。而是使用以下内容:

animateWithDuration:delay:options:animations:completion:

我想您遇到的无限递归与 Apple 提出该建议的原因有关。

【讨论】:

  • 感谢您的提示,现在开始制作动画了。不幸的是,动画开始后应用程序阻塞并且用户输入不再可能。也只有 n 个 tableViewCells 中的第一个让动画工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多