So, I've got a Table View where I pre-draw the Views of the section headers'. So everything works fine but as soon as the header gets offscreen the animation of the view won't restart. Btw I'm saving the pre-drawn views in an array and setNeedsDisplay does not work on the view and it slows down the performance significantly.
here is the code:
I appreciate any help!!!
EDIT:
I thought maybe it stops the animation because it can not change the alpha value as soon as it goes offscreen and once it's stop it won't restart if it comes back on screen but how could i restart the animation?
is there a method like UIView viewdidAppear?
EDIT:
I think I found my mistake. It seems like that each header as it goes offscreen releases its opacity instance which is a CABasicAnimation. So I think the solution is to create a CALayer which can hold the CABasicAnimation even if it goes off screen. And afterwards add the CALayer to a UIView and everything should work than.
here is the code:
Code:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerSection = [headerArray objectAtIndex:section];
[UIView animateWithDuration:1.0f delay:0.0f
options: (UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction)
animations:^{ headerSection.alpha = 0.50f; } completion:nil];
header = [headerSArray objectAtIndex:section];
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)] autorelease];
[view addSubview:header];
[view addSubview:headerSection];
return view;
}
I appreciate any help!!!
EDIT:
I thought maybe it stops the animation because it can not change the alpha value as soon as it goes offscreen and once it's stop it won't restart if it comes back on screen but how could i restart the animation?
is there a method like UIView viewdidAppear?
EDIT:
I think I found my mistake. It seems like that each header as it goes offscreen releases its opacity instance which is a CABasicAnimation. So I think the solution is to create a CALayer which can hold the CABasicAnimation even if it goes off screen. And afterwards add the CALayer to a UIView and everything should work than.
Last edited: