Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm a dummy, but how to set section header? #61

Closed
rablador opened this issue Feb 18, 2018 · 5 comments
Closed

I'm a dummy, but how to set section header? #61

rablador opened this issue Feb 18, 2018 · 5 comments

Comments

@rablador
Copy link

rablador commented Feb 18, 2018

I have:

SearchResultSectionHeader - UIView with matching nib, implements ModelTransfer
SearchResultSectionHeaderModel - Model for the above

I've tried (in all combinations):

manager.registerHeader(SearchResultSectionHeader.self)
manager.memoryStorage.setSectionHeaderModel(SearchResultSectionHeader.self, forSection: 0)
manager.memoryStorage.setSectionHeaderModel(SearchResultSectionHeaderModel.self, forSection: 0)

Still can't see my custom section header view in the table. I have populated the table with cells. I must be doing something wrong, but what?

@yurikoles
Copy link
Contributor

@rablador please use markdown syntax for you code.

@DenTelezhkin
Copy link
Owner

Try setting header height to some non-zero value.

@rablador
Copy link
Author

rablador commented Feb 19, 2018

@DenHeadless No change.

Current configuration is as follows:

SearchResultSectionHeader.swift

class SearchResultSectionHeader: UIView, ModelTransfer {
    @IBOutlet private weak var title: UILabel!
    
    func update(with model: SearchResultSectionHeaderModel) {
        title.text = model.title
    }
}

SearchResultSectionHeaderModel.swift

class SearchResultSectionHeaderModel {
    var title: String!
}

In view controller - viewDidLoad

tableView.sectionHeaderHeight = 30
manager.registerHeader(SearchResultSectionHeader.self)

@DenTelezhkin
Copy link
Owner

And you should also set header model, for example like so:

manager.memoryStorage.setSectionHeaderModel(SearchResultsSectionHeaderModel(), forSection: 0)

@rablador
Copy link
Author

Ah, I did not realise I have to set an actual model object! Well, problem solved. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants