Reputation: 183
If I add custom uitableView sectionheader using storyboard I get this error AX ERROR: Could not find my mock parent, most likely I am stale.
What does this error mean and how can I solve it? Header code:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
static NSString *cellID = @"sectionHeaderID";
UITableViewCell *headerview = [tableView dequeueReusableCellWithIdentifier:cellID];
return headerview;
}
Upvotes: 1
Views: 4936
Reputation: 308
Actually if you look at the comments in the post you linked pedro.m, gives a possible solution. He added a subview to the cell he calls contentView then returns it.
What I did was a bit simpler:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
static NSString *cellID = @"sectionHeaderID";
UITableViewCell *headerview = [tableView dequeueReusableCellWithIdentifier:cellID];
return headerview.contentView;
}
This fixed the error for me.
Upvotes: 5
Reputation: 5226
Section header is not the same as table view cell. You should create your own UIView for the header view instead of taking it from table view cell. For example:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerview = [[UIView alloc] initWithFrame:CGRectMake(0,0,CGRectGetWidth(self.view.frame), 100.0)];
return headerview;
}
Upvotes: 4