2012-08-14 54 views
0

我正在使用GMGridview的應用程序中工作。我在cellforItems方法中添加了按鈕。 -翻轉動畫不能在GMGridview中工作

(GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index 
{ 
    NSLog(@"Creating view indx %d", index); 

    CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; 

    GMGridViewCell *cell = [gridView dequeueReusableCell]; 

    if (!cell) 
    { 
     cell = [[GMGridViewCell alloc] init]; 
     cell.deleteButtonIcon = [UIImage imageNamed:@"close_x.png"]; 
     cell.deleteButtonOffset = CGPointMake(-15, -15); 

    } 

    [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)]; 


    btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [btn setTag:index]; 


    [btn setFrame:CGRectMake(0, 0,size.width, size.height)]; 
    NSLog(@"button frame is %@",btn); 

    [[btn layer] setBorderColor:[UIColor redColor].CGColor]; 
    [[btn layer]setBorderWidth:2.0f]; 
    [btn addTarget:self action:@selector(SegmentChange:) forControlEvents:UIControlEventTouchUpInside]; 

    cell.contentView = btn; 
    //int btntag=btn.tag; 

return cell; 

後來我就用什麼方法來翻轉所有的按鈕,但它不工作,我想是當我點擊翻頁按鈕在GridView所有的按鈕應該flip.how我能做到這一點,倒裝代碼我用的就是這裏,

for(ll=0;ll<[Image_array count];ll++) 
    { 
     // [UIView setAnimationDelay:2.0]; 
     [UIView beginAnimations:@"BackButton" context:nil]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
     [UIView setAnimationDuration:12.0]; 

     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:btn cache:YES]; 
     [UIView setAnimationDelegate:self]; 
     [UIView commitAnimations]; 
     [btn setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal]; 
     [arr_check replaceObjectAtIndex:ll withObject:@"uncheck"]; 

     front = NO; 


    } 
     [_gmGridView reloadData]; 

回答

0

我已刪除從循環的代碼,並在cellForItemAtIndexpath使用相同的代碼,並使用單元格比按鈕

這裏翻蓋代碼:

 [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell cache:YES]; 

     [UIView setAnimationDuration:0.7]; 
     [UIView setAnimationDelegate:self]; 
     [UIView commitAnimations]; 
0

由於FOR循環非常快很多比較UIViewAnimation。所以,即使它動畫您的視圖,您也無法看到動畫效果。

您可以使用NSTimerUIViewAnimationUIViewAnimation委託方法確定是否完成一個視圖翻轉事件。然後從代理方法(UIViewAnimation)開始另一個視圖動畫。

+0

沒能得到,使用定時器 – Purva 2012-08-14 12:48:21

+0

@Purva:使用'timerWithTimeInterval'和用於翻轉UIView的方法。 – Devang 2012-08-14 12:52:29