UA-17470720-3

Jump to content


Photo
- - - - -

STV 4.0 Change Section Header Height


  • Please log in to reply
1 reply to this topic

#1 Kourghan

Kourghan

    Starting Out

  • STV Lite
  • Pip
  • 1 posts
Reputation: 0
Neutral

Posted 01 April 2015 - 06:15 AM

Hello! 

Is it possible to change section header height depending on section item count? I want to hide section header if there is no items in it. 
I was trying to use something like this
 

 

self.tableViewModel.sectionActions.willDeleteItem = ^BOOL(SCArrayOfItemsSection *itemsSection, NSObject *item, NSIndexPath *indexPath) {
        if ([itemsSection.items count] == 1) {
           itemsSection.headerHeight = 0.f;
        }
        
        return YES;
    };
 

But it doesn't work.

Thank you in advance!



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 03 April 2015 - 08:53 AM

Hi Kourghan,

 

Your approach is correct, but there are two issues here:

 

1. You need to reload the table view whenever you change a section's headerTitle, headerView, headerHeight, etc. This is best done at 'didDeleteItem' instead of 'willDeleteItem'.

2. A headerHeight of zero simply tells STV to automatically calculate the height for whatever you have there. Perhaps we should change the way STV treats a zero headerHeight, and have it do its automatic calculations when headerHeight is -1 for instance. If you must set the headerHeight for now, you can set it to a very small value: 'itemsSection.headerHeight = 0.01f'. Alternatively, you also either set 'itemsSection.headerTitle = nil', or 'itemsSection.headerView = [[UIView alloc] initWithFrame:CGRectZero]'.

 

Here is a code sample:

 

self.tableViewModel.sectionActions.didDeleteItem = ^(SCArrayOfItemsSection *itemsSection, NSIndexPath *indexPath)
    {
        if ([itemsSection.items count] == 0) {
            itemsSection.headerHeight = 0.01f;
            [self.tableViewModel.tableView reloadData];
        }
    };

 

 

Again, we will update STV very soon so that you could use 'headerHeight = 0.0f' instead (won't make any difference to the end result though). Hope this helps.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users