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

willDisplayHeaderView and willDisplayFooterView #83

Closed
sushant-here opened this issue May 25, 2018 · 3 comments
Closed

willDisplayHeaderView and willDisplayFooterView #83

sushant-here opened this issue May 25, 2018 · 3 comments
Labels

Comments

@sushant-here
Copy link

Hi,
I noticed that there is no way to get callbacks for willDisplayHeaderView and willDisplayFooterView. Is there any plans to add this and/or suggestion on how I can access those?

Thanks,
Sushant

@maxsokolov
Copy link
Owner

maxsokolov commented May 30, 2018

Hey @Sushant40

Sorry for late response. I don't have plans to add method that you have mentioned. But there is an easy way to support them.

final class MyTableDirector: TableDirector {
    
    func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) 
    {
        invoke(action: .custom("my_event"), cell: nil, indexPath: indexPath)
    }
}

and then catch your event with a row action.

@gurgeous
Copy link

Thanks for creating such a great library, much appreciated!

I am commenting on this ancient issue to leave a hint for anyone else trying to implement this callback. The suggested fix is a difficult one - I don't think you can easily use invoke for willDisplayFooterView because it's a section thing, not a row action. If I'm understanding things correctly, you'd have to create a fake indexPath and add your handler to every row.

You'll have better luck just doing your work directly in a TableDirector subclass, or calling back into some other class via a custom delegate.

@maxsokolov
Copy link
Owner

maxsokolov commented Jun 12, 2020

Hey @gurgeous, thank you for the comment!

You are right. Suggested solution is not the best one. And agree with you, something like this could work better.

final class MyTableDirector: TableDirector {

    var onWillDisplayFooterView: ((_ section: Int) -> ())?
    
    func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
        onWillDisplayFooterView?(section)
    }
}

tableDirector.onWillDisplayFooterView = { [weak self] section in
}

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

No branches or pull requests

3 participants