Search code examples
iphoneipadios5xcode4.2gmgridview

Flip animation not working in GMGridview


I am working in an app in which i have used the GMGridview. I have added the buttons in cellforItems method. -

 (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;

then I have used the method to Flip all the buttons,but its not working , What i want is when i click on flip button all the buttons in the gridview should flip.how can i do this ,the code for flip i use is here,

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];

Solution

  • i have removed the code from for loop and used the same code in the cellForItemAtIndexpath and use the cell to flip than the button

    here is the code :

            [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell cache:YES];
    
            [UIView setAnimationDuration:0.7];
            [UIView setAnimationDelegate:self];
            [UIView commitAnimations];