Search code examples
objective-cuicollectionviewuicollectionviewcelltvosapple-tv

TVOS , UICollectionViewCell , animation


i have one collectionView and i want to use animation in previouslyFocusedView and nextFocusedView

here is my first part off code it's work

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    CCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];




    [cell.lbl_My setText:[title_My objectAtIndex:indexPath.row]];


    return cell;
}

i don't know how to call the "cell" in this part

- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context
       withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{




    if (context.previouslyFocusedView){

        //how to call the "cell" here


    } else if (context.nextFocusedView){



    }

}

and i want to add the animation like this

[UIView animateWithDuration:0.1
                              delay:0.1
                            options:UIViewAnimationOptionTransitionCrossDissolve
                         animations:^{
                             //yourAnimation
                         } completion:^(BOOL finished){
                             NSLog(@"Animation is finished");
                         }];

and here is my

CGSize prev =CGSizeMake(286  , 223);
    CGSize next =CGSizeMake(314.6  , 245.3);

how call i use the CGsize and animation in - (void)didUpdateFocusInContext this function


Solution

  • just do something like this:

    if ([context.previousFocusedView isKindOfClass:[MyCell class]]) {
      MyCell *cell = (MyCell*)context.previousFocusedView;
      // do whatever you need with cell
    }