【发布时间】:2015-03-09 09:02:08
【问题描述】:
我正在开发一个带有 Cell 的 UICollectionViewController,其中包含在显示时动画的内部“UIView”(只是一个简单的 y 轴移动)。
我的问题是,首先从 nib 文件加载单元格,动画不运行,但单元格被“重用”,动画正在运行。
这就是我的工作:
- (void)loadCellWithAnimation{
CGRect prevRect = self.viewThatAnimates.frame;
prevRect.origin.y = prevRect.origin.y+10;
[UIView animatewithDuration:0.5f animations:^{self.viewThatAnimates.frame = prevRect}];
}
在我的 collectionViewController 上:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
[cell loadCellWithAnimation];
return cell;
}
正如我所说,“重用”动画效果很好,但从笔尖唤醒时它不会运行。
我已经在几种不同的情况下对此进行了测试,结果始终相同。
感谢您的帮助;)
【问题讨论】:
-
一点点补充,当我运行动画块有一点延迟(dispatch_after 有 0.05 秒延迟)时,动画可以运行
标签: ios objective-c animation uicollectionview uiviewanimation