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

Setting hidden to true doesn't hide row #307

Closed
rlaferla opened this issue Mar 3, 2016 · 12 comments
Closed

Setting hidden to true doesn't hide row #307

rlaferla opened this issue Mar 3, 2016 · 12 comments

Comments

@rlaferla
Copy link
Contributor

rlaferla commented Mar 3, 2016

When I set up my row, I can toggle it's visibility BUT when I later try to change the visibility, it does not work.

        var row:BaseRow

        row = TextRow() {
            $0.tag = "first"
            $0.title = "First:"
            $0.hidden = false
            }.cellSetup({ (cell, row) -> () in
                cell.textField.autocorrectionType = .No
            })
        section <<< row

then in another method:

        self.form.rowByTag("first")!.hidden = true  // This should hide the row but it doesn't.

I am using 1.3.1 via CocoaPods.

@rlaferla
Copy link
Contributor Author

rlaferla commented Mar 3, 2016

The tags do match. e.g. first = first. There was a typo in my example which I just corrected.

@rlaferla
Copy link
Contributor Author

rlaferla commented Mar 3, 2016

I also updated to 1.4.1 and it still doesn't work.

@rlaferla
Copy link
Contributor Author

rlaferla commented Mar 3, 2016

I created a simple test project to show this issue. This is definitely a bug:

import UIKit
import Eureka

class ViewController: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        var section:Section
        var row:BaseRow

        section = Section("Section")

        form +++ section

        row = TextRow() {
            $0.tag = "first"
            $0.title = "First Name:"
        }
        section <<< row

        row.hidden = true
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

@rlaferla
Copy link
Contributor Author

rlaferla commented Mar 3, 2016

It works IF I change the code to:

row.hidden = true
row.evaluateHidden()

I don't see any information in the documentation that says that evaluateHidden() needs to be called.

@rlaferla
Copy link
Contributor Author

rlaferla commented Mar 3, 2016

Also, even though my bug workaround hides the rows, the height of the tableview does not shrink. When hiding rows, I need the table view to adjust it's size so that other views onscreen can claim that space. I tried calling sizeToFit() and setting the tableview frame to contentSize.height but neither worked.

I think the row height for hidden cells needs to be set to zero for the tableview to change it's height. This worked fine in XLForm but does not work in Eureka. I'm beginning to regret switching to Eureka.

@mtnbarreto
Copy link
Member

@rlaferla Here you have the documentation for the evaluateHidden(): https://github.com/xmartlabs/Eureka#row-does-not-update-after-changing-hidden-or-disabled-condition , it's within FAQ readme section.

In regards of the table view height issue, whenever you hide a row, the row is completely removed from the table view so I don't think changing the row height is a good approach.

If you want to change the table view height i suggest you to use interface builder to create the view controller adding corresponding "height" constraint and updating its constant accordingly when rows are removed.

Take into account that rows are removed with animation so it may take some time to get the proper tableView contentSize value.

I'm gonna close the issue since for now since It's seems not directly related with eureka.
I'm willing to provide morehelp in case you share a project reproducing the issue.

@rlaferla
Copy link
Contributor Author

rlaferla commented Mar 5, 2016

I think this should be mentioned in the readme under the section: "How to dynamically hide and show rows (or sections)" It's not obvious.

@johnpaulmanoza
Copy link

Got stucked with the same issue. Can we make it obvious to the documentation?

@wsimf
Copy link

wsimf commented Sep 27, 2017

I think this should also be clearly mentioned in the main documentation. I might not be the only one getting stuck with this same issue.

@simonbromberg
Copy link

simonbromberg commented Jan 2, 2018

I am experiencing a similar issue with a MultivaluedSection where I am trying to hide the add button in the multivaluedRowToInsertAt block and I am calling evaluateHidden but it only hides the row when the 6th row is added (no matter what condition I check).

EDIT: changed it so it calls the evaluateHidden() method inside an asynchronous block using:

DispatchQueue.main.async() {
    self.myButtonRow.evaluateHidden()
}

And then it started working as expected.

No idea why this is necessary though. The insert row provider block is already executing on the main thread when it is called.

@rrodrigo-sa
Copy link

rrodrigo-sa commented Jan 29, 2022

Got stucked with the same issue. Can we make it obvious to the documentation?

I think this should also be clearly mentioned in the main documentation. I might not be the only one getting stuck with this same issue.

I got stuck with the same problem. Maybe it would indeed be nice to put it in the main part of the documentation.

@mats-claassen
Copy link
Member

Done!

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

No branches or pull requests

7 participants