ShinobiDataGrid styleForSectionHeaderAtIndex


#1

Hi there, I am using  XCode 6 & ShinobiDataGrid 2.7.2-5 & the background section header color is not reflected

This was not the case under Xcode 5 and an older version of ShinobiDataGrid. 

test case:

- (SDataGridSectionHeaderStyle *)shinobiDataGrid:(ShinobiDataGrid *)grid styleForSectionHeaderAtIndex:(NSInteger)sectionIndex
{
    switch (sectionIndex) {
        case 0:
            DDLogInfo(@"return style for site section header");
            return [[SDataGridSectionHeaderStyle alloc] initWithHeight:45 withBackgroundColor:[UIColor colorWithRed:215.0 / 255.0 green:79.0 / 255.0 blue:42.0 / 255.0 alpha:1.0] withHidden:NO];
        case 1:
            return [[SDataGridSectionHeaderStyle alloc] initWithHeight:65 withBackgroundColor:[UIColor colorWithRed:32.0 / 255.0 green:141.0 / 255.0 blue:190.0 / 255.0 alpha:1.0] withHidden:NO];
        case 2:
            return [[SDataGridSectionHeaderStyle alloc] initWithHeight:65 withBackgroundColor:[UIColor colorWithRed:16.0 / 255.0 green:160.0 / 255.0 blue:98.0 / 255.0 alpha:1.0] withHidden:NO];
        case 3:
            return [[SDataGridSectionHeaderStyle alloc] initWithHeight:65 withBackgroundColor:[UIColor colorWithRed:229.0 / 255.0 green:176.0 / 255.0 blue:43.0 / 255.0 alpha:1.0] withHidden:NO];
        default:
            return nil;
    }
}
 
 You can see the height being reflected but not the background color. Any suggestions ? thanks.

#2

Same thing here :frowning:


#3

Greetings Programs!

I’ve gone back and found that version 2.7.1 Hotfix 1 was the last version in which it was working correctly (in Xcode 6 & 5). After that, it’s broken; I’d say it’s a bug.

Wg


#4

So Chris Grant from Shinobi Squad confirmed it was a bug and he’s fixed it for the next release (unknown date). In the meantime, the workaround was to use the “viewForHeaderInSection:inFrame:” method to return a custom view with the background set and let the “styleForSectionHeaderAtIndex:” take care of the rest.

This is what I did with the DataGridWithSections sample app:

- (UIView *)shinobiDataGrid:(ShinobiDataGrid *)grid viewForHeaderInSection:(NSInteger)sectionIndex inFrame:(CGRect)frame
{
    
    UIView *headerView = [[UIView alloc] initWithFrame:frame];

    UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, frame.size.width-40, frame.size.height)];
    headerLabel.backgroundColor = [UIColor clearColor];
    headerLabel.opaque = NO;
    headerLabel.textColor = [UIColor blackColor];
    headerLabel.highlightedTextColor = [UIColor whiteColor];
    headerLabel.font = [UIFont systemFontOfSize:16];
    [headerView addSubview:headerLabel];
    
    PersonGroup *group = self.data[sectionIndex];
    headerLabel.text = group.letter;
    
    switch (sectionIndex) {
            
        case 0:
            
            [headerView setBackgroundColor:[UIColor colorWithRed:215.0 / 255.0 green:79.0 / 255.0 blue:42.0 / 255.0 alpha:1.0]];
            break;
            
        case 1:
            
            [headerView setBackgroundColor:[UIColor colorWithRed:32.0 / 255.0 green:141.0 / 255.0 blue:190.0 / 255.0 alpha:1.0]];
            break;
            
        case 2:
            
            [headerView setBackgroundColor:[UIColor colorWithRed:16.0 / 255.0 green:160.0 / 255.0 blue:98.0 / 255.0 alpha:1.0]];
            break;
            
        case 3:
            
            [headerView setBackgroundColor:[UIColor colorWithRed:229.0 / 255.0 green:176.0 / 255.0 blue:43.0 / 255.0 alpha:1.0]];
            break;
            
        default:
            [headerView setBackgroundColor:[UIColor lightGrayColor]];
            break;
    }
    
    return headerView;
}

Wg


#5

Hi Richard,

We’ve just released version 2.7.2.hotfix2 which should contain a fix for this issue. This version is available in the customer portal for existing customers. Unfortunately, trialists will have to wait until our next minor release.

Best regards,
Jan Akerman