I'm trying to implement a custom header view for a table (not section header) with a slick scroll and I'm getting the scroll to work, but it's crashing my app when I unwind the segue. Is the header view not being released or something? An exception breakpoint isn't helping.
Here's the code for the tableview:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.headView = [HappyHourHeaderView headerInit];
self.headView.height = 200.0f;
self.headView.headerImage.height = 200.0f;
self.headView.headerImage.y = 0.0f;
self.headView.headerImage.contentMode = UIViewContentModeScaleAspectFill;
self.tableView.tableHeaderView = self.headView;
}
Here's the code for the custom header view:
@implementation HappyHourHeaderView
+(instancetype)headerInit
{
HappyHourHeaderView *tableHeader = nil;
NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"HappyHourHeaderView" owner:nil options:nil];
tableHeader = objects[0];
tableHeader.headerImage.image = [UIImage imageNamed:@"theImage"];
tableHeader.headerImage.frame = CGRectMake(0, 0, tableHeader.width, tableHeader.height);
tableHeader.clipsToBounds = YES;
return tableHeader;
}
-(void)tableDidScrollWithY:(float)y{
float constant = y + 64;
if (constant >= 0) {
self.clipsToBounds = YES;
self.headerImage.y = MAX(0, constant - (constant * 0.4));
self.headerImage.height = 200;
}
else{
self.clipsToBounds = NO;
self.headerImage.y = MIN(0, constant);
self.headerImage.y = 0;
self.headerImage.height = 200 - constant;
}
self.height = 200;
self.y = 0;
self.headerImage.clipsToBounds = YES;
}
@end