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.
The tags do match. e.g. first = first. There was a typo in my example which I just corrected.
I also updated to 1.4.1 and it still doesn't work.
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.
}
}
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.
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.
@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.
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.
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 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.
Most helpful comment
It works IF I change the code to:
I don't see any information in the documentation that says that evaluateHidden() needs to be called.