2013-02-05 66 views
0

所以,我正在使用AQGridView。我們有定製的單元格和圖片。現在我們希望圖片在點擊時反彈。我試圖在圖像的框架上進行操作,但那不起作用,所以現在我試圖在主視圖中創建一個UIImageView並給出一個路徑動畫,但最終發生的事情是該視圖出現在左上角有問題的細胞的走廊。這是相關的代碼。AQGridView單元格中的自定義動畫會立即發生?

-(void)bounce:(CoverGridCell*)v { 
    UIView * w = [v.subviews objectAtIndex:0]; 
    UIImageView * u = [[UIImageView alloc] initWithImage:v.image]; 
    u.frame = [self.view convertRect:[[w.subviews objectAtIndex:0] frame] fromView:w]; 
    double __block y = u.frame.origin.y; 
    double __block x = u.frame.origin.x; 
    [self.view addSubview:u]; 
    CGMutablePathRef cgmp = CGPathCreateMutable();for (int j= 10; j > 0;j--) { 
     CGAffineTransform t1 = CGAffineTransformMakeTranslation(0, - j*j); 
     CGAffineTransform t2 = CGAffineTransformInvert(t1); 
     CGPathMoveToPoint(cgmp,&t1, x, y - j * j); 
     CGPathMoveToPoint(cgmp,&t2, x, y); 
    } 
    CGPathRef cgp = CGPathCreateCopy(cgmp); 

    CGPathRelease(cgmp); 

    CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath: @"position"]; 
    anim.duration = 5.0; 
    anim.delegate = self; 
    anim.path = cgp; 
    anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 
    [u.layer addAnimation:anim forKey:@"DoesThisMatter"]; 
    [u.layer setPosition:CGPointMake(x,y)]; 
} 

回答

0

這是一個線程問題,IIRC。點擊單元格時發生的事情是凍結「Pad」直到動畫結束。