UIView animation inside UITableViewCell
I think you should implement one more delegate
method of UITableView
, which is -
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
& perform your animations on the respective view of the respective cell inside it.
The below method will be called every time the cell is displayed, (also in case if it goes out of the TableView's frame and comes back to the visible area)
-(void) tableView:(UITableView *) tableView willDisplayCell:(UITableViewCell *) cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
//row number on which you want to animate your view
//row number could be either 0 or 1 as you are creating two cells
//suppose you want to animate view on cell at 0 index
if(indexPath.row == 0) //check for the 0th index cell
{
// access the view which you want to animate from it's tag
UIView *myView = [cell.contentView viewWithTag:MY_VIEW_TAG];
// apply animation on the accessed view
[UIView animateWithDuration:1.2
delay:0
options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseInOut animations:^
{
[myView setAlpha:0.0];
} completion:^(BOOL finished)
{
[myView setAlpha:1.0];
}];
}
}