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

Headers from 1 section overlapping into text from another section #32

Open
DrD00der opened this issue Oct 24, 2017 · 7 comments
Open

Headers from 1 section overlapping into text from another section #32

DrD00der opened this issue Oct 24, 2017 · 7 comments

Comments

@DrD00der
Copy link

I made my table sections auto collapse when you open any other section via for loops. One of my testers sent me these screenshots showing that the various fields from each section seem to get overlapped by headers from other sections.

I used the exact code from this repository and changed only a few lines of code to make the sections auto close and customized the data in ExampleData.swift.

In the CollapsibleTableViewController.swift, I added this into viewDidLoad:

                for index in 0 ..< sections.count {
                        sections[index].collapsed = true
    
                }

I updated my toggleSelection code as follows:

    func toggleSection(_ header: CollapsibleTableViewHeader, section: Int) {
        let collapsed = !sections[section].collapsed
        print("section = \(section)")
        // Toggle collapse
        print("toggle collapse")
        sections[section].collapsed = collapsed
        print("sections.count = \(sections.count)")
        let count = sections.count - 1
        for index in 0 ... count {
            if index != section {
                sections[index].collapsed = true
            }

        }
        header.setCollapsed(collapsed)
        tableView.reloadSections(IndexSet(integersIn: 0...sections.count-1), with: .automatic)
    }

Here is the screenshot of the bug in action:
image

Any ideas what could be causing this? I can't replicate this in my testing but my tester keeps having this happen.

Thanks

@DrD00der
Copy link
Author

Update: been investigating this and it appears to be caused by iOS 11 changing how tableview estimated heights are handled.

If I figure out a fix, will post it.

@jeantimex
Copy link
Owner

Thank you so much @DrD00der!

@jeantimex
Copy link
Owner

Also I am thinking upgrading to Swift 4

@DrD00der
Copy link
Author

Problem solved:

Remove the sizing from viewDidLoad and add them in viewWillAppear:

    override func viewWillAppear(_ animated: Bool) {
        tableView.estimatedRowHeight = 75
        tableView.rowHeight = UITableViewAutomaticDimension
        
        tableView.estimatedSectionFooterHeight = 75
        tableView.sectionFooterHeight = UITableViewAutomaticDimension
        
        tableView.estimatedSectionHeaderHeight = 75
        tableView.sectionHeaderHeight = UITableViewAutomaticDimension
    }

@sourabh31
Copy link

img_0097
overlapping when expanding section
is it any solution regarding overlapping problem

for better understanding see attachment file

@AdminOfUbriter
Copy link

UITableViewAutomaticDimension never works on my project in term of setting proper section header height.

@adamirowe
Copy link

Problem solved:

Remove the sizing from viewDidLoad and add them in viewWillAppear:

    override func viewWillAppear(_ animated: Bool) {
        tableView.estimatedRowHeight = 75
        tableView.rowHeight = UITableViewAutomaticDimension
        
        tableView.estimatedSectionFooterHeight = 75
        tableView.sectionFooterHeight = UITableViewAutomaticDimension
        
        tableView.estimatedSectionHeaderHeight = 75
        tableView.sectionHeaderHeight = UITableViewAutomaticDimension
    }

Why is this a fix?

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

5 participants