1

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;
}
Community
  • 1
  • 1
akin
  • 183
  • 2
  • 13

2 Answers2

5

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.

m1sk
  • 308
  • 2
  • 10
4

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;
}
Valent Richie
  • 5,226
  • 1
  • 20
  • 21
  • Thanks actually I do so, I just want to custom headerView with storyboard, At last , I give up and use code to init header view – akin May 23 '13 at 10:42