Iphone 当应用CAAnimation时,AQGridView单元格将交换
是否有人成功地将动画应用于Iphone 当应用CAAnimation时,AQGridView单元格将交换,iphone,ios,ipad,caanimation,aqgridview,Iphone,Ios,Ipad,Caanimation,Aqgridview,是否有人成功地将动画应用于AQGridViewCells?我试着让每一个细胞,但第一个细胞在一次敲击后消失 问题是,当淡入淡出开始时,单元格内容通常会交换。例如,如果栅格视图的第一行包含带有标签“1”、“2”、“3”的单元格,则标签可能会被替换为“1”、“3”、“2” 我尝试在一组AQGridView、AQGridViewCell等方法中设置断点,以试图找到导致交换的断点。找不到 在已知的AQGridView错误中,存在以下问题: 不要试图将多个动画叠加在一起。即 不要在-Isanimating
AQGridViewCell
s?我试着让每一个细胞,但第一个细胞在一次敲击后消失
问题是,当淡入淡出开始时,单元格内容通常会交换。例如,如果栅格视图的第一行包含带有标签“1”、“2”、“3”的单元格,则标签可能会被替换为“1”、“3”、“2”
我尝试在一组AQGridView
、AQGridViewCell
等方法中设置断点,以试图找到导致交换的断点。找不到
在已知的AQGridView
错误中,存在以下问题:
不要试图将多个动画叠加在一起。即
不要在-IsanimatingUpdate的网格视图上调用-BeginUpdate
方法返回YES。不好的事情会发生,细胞会在
错误的地方,叠在一起
在上述代码中,-isAnimatingUpdates
返回NO
。即便如此,也许我看到的是AQGridView
中的另一个相关bug——我将提交一份bug报告。但由于我的例子如此简单,我想知道是否有人曾经遇到过这种情况,并找到了一种解决方法,也许是某种关闭AQGridView
内部动画的方法
编辑
为了查看问题是否与
hidden
属性有关,我设置了单元格不透明度的动画(尝试了上述两种方法)。即使不透明度仅降至0.5而不是0.0,单元仍在交换 这里有一个解决方法。如果有人找到一个更优雅的解决方案,我会把它作为答案
- (void)gridView:(AQGridView *)aGridView didSelectItemAtIndex:(NSUInteger)index
{
// Create a copy of the 0th cell's content and display it on top of that cell.
AQGridViewCell *selectedCell = [aGridView cellForItemAtIndex:0];
UILabel *selectedLabel = [[selectedCell.contentView subviews] objectAtIndex:0];
CGRect frame = [self.view convertRect:selectedLabel.frame fromView:selectedLabel.superview];
UILabel *labelOnTop = [[UILabel alloc] initWithFrame:frame];
labelOnTop.text = selectedLabel.text;
[self.view addSubview:labelOnTop];
[labelOnTop release];
// Fade away the grid view as a whole (not individual cells).
CATransition *cellAnimation = [CATransition animation];
cellAnimation.duration = 3.0;
cellAnimation.type = kCATransitionFade;
cellAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[aGridView.layer addAnimation:cellAnimation forKey:kCATransition];
aGridView.hidden = YES;
}
这里有一个解决办法。如果有人找到一个更优雅的解决方案,我会把它作为答案
- (void)gridView:(AQGridView *)aGridView didSelectItemAtIndex:(NSUInteger)index
{
// Create a copy of the 0th cell's content and display it on top of that cell.
AQGridViewCell *selectedCell = [aGridView cellForItemAtIndex:0];
UILabel *selectedLabel = [[selectedCell.contentView subviews] objectAtIndex:0];
CGRect frame = [self.view convertRect:selectedLabel.frame fromView:selectedLabel.superview];
UILabel *labelOnTop = [[UILabel alloc] initWithFrame:frame];
labelOnTop.text = selectedLabel.text;
[self.view addSubview:labelOnTop];
[labelOnTop release];
// Fade away the grid view as a whole (not individual cells).
CATransition *cellAnimation = [CATransition animation];
cellAnimation.duration = 3.0;
cellAnimation.type = kCATransitionFade;
cellAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[aGridView.layer addAnimation:cellAnimation forKey:kCATransition];
aGridView.hidden = YES;
}