UA-17470720-3

Jump to content


Photo
- - - - -

Section customisation


  • This topic is locked This topic is locked
10 replies to this topic

#1 skrew

skrew

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 21 posts
Reputation: 3
Good

Posted 18 October 2015 - 04:08 AM

Hi,

 

In my code, i use:

 

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
    view.tintColor = [UIColor colorWithWhite:0.5f alpha:0.5f];
    
    UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
    [header.textLabel setTextColor:[UIColor whiteColor]];
}
 

But i don't see any block action for making the same things with your library.

 

I'd missed something ?

 

 

Thanks

 

Edit: I know i can subclass SCTableViewModel but it overloading my code, where you can just add a sectionActions.willDisplayHeaderView block to make the same.


Edited by skrew, 18 October 2015 - 04:33 AM.


#2 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 18 October 2015 - 02:59 PM

Greetings Program!

Have you tried the didAddToModel section action? http://sensiblecocoa...e/didAddToModel

Wg

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#3 skrew

skrew

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 21 posts
Reputation: 3
Good

Posted 18 October 2015 - 03:02 PM

Hi wizgod,

 

Yes tested, and section.view are nil.



#4 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 19 October 2015 - 01:37 AM

forum search.. quickest way to find that many before you have asked the same questions and they have been answered

 

maybe something like this one             #6            

or is you use search for headerview there are other threads


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#5 skrew

skrew

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 21 posts
Reputation: 3
Good

Posted 19 October 2015 - 05:26 AM

I always search before asking on forum... Sometime i don't found (because i don't use the good keywords) but i don't always fail ;)

 

I don't want to create another headerView, i just want to change the headerView managed by UITableView.

 

Subclassing SCTableViewModel works, but it overload the code. A simple sectionActions.willDisplayHeaderView will be fine..



#6 Matt Huss

Matt Huss

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
Reputation: 4
Good

Posted 19 October 2015 - 09:38 AM

In STV you simply set the section header to the section's headerView property. Is that what you're looking for?


  • Tarek likes this

#7 skrew

skrew

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 21 posts
Reputation: 3
Good

Posted 19 October 2015 - 10:02 AM

self.tableViewModel.modelActions.didAddSection = ^(SCTableViewModel *tableModel, SCTableViewSection *section, NSUInteger sectionIndex)
    {
        SKLog(@"view: %@", section.headerView); -> NIL
    };
sectionGlobal.sectionActions.didAddToModel = ^(SCTableViewSection *section, NSUInteger sectionIndex)
    {
        SKLog(@"view: %@", section.headerView); -> NIL
    };
self.tableViewModel.sectionActions.didAddToModel = ^(SCTableViewSection *section, NSUInteger sectionIndex)
    {
        SKLog(@"view: %@", section.headerView); -> NIL
    };

 

Nothing to do, i looked in SensibleCocoa source code, there are nothing about tableView:willDisplayHeaderView:forSection ...



#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 19 October 2015 - 11:18 AM

Hi Screw,

 

Here is a code sample of what Matt is suggesting:

 

- (void)viewDidLoad
{
  [super viewDidLoad];

  SCTableViewSection *mySection = [self.tableViewModel sectionAtIndex:0];

  UITableViewHeaderFooterView *headerView = [[UITableViewHeaderFooterView alloc] init];
  [headerView.textLabel setTextColor:[UIColor whiteColor]];
  headerView.textLabel.text = @"My Header";

  mySection.headerView = headerView;
}

 

We can also add a new sectionAction called willDisplayHeaderView if you wish, but usually the above code should work. 

 

Hope this helps.


Edited by Tarek, 19 October 2015 - 11:22 AM.
typo


#9 skrew

skrew

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 21 posts
Reputation: 3
Good

Posted 19 October 2015 - 01:18 PM

Hi Tarek,

 

This controller don't use storyboard, all are done by code. I have 4 sections in this controller.

Your solution suggest to create UITableViewHeaderFooterView, that i don't want to do, iOS make this job already.

 

tableView:willDisplayHeaderView:forSection exists for what i want to do, just changing background color and text color.

 

I will stay with subclassing for now.



#10 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 19 October 2015 - 01:31 PM

what about

modelActions.didAddSection = ^(SCTableViewModel *tableModel, SCTableViewSection *section, NSUInteger sectionIndex)
{
    UIView *view = section.headerView;
    //change properties here?
};

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#11 skrew

skrew

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 21 posts
Reputation: 3
Good

Posted 19 October 2015 - 01:41 PM

Thanks Ozie, but it's already tested. I will lock this topic for now (Tarek, tell me if it's a problem).






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users