Hi guys.
I'm trying to hide/show some sections via a SwitchRow, and the only animation available is the rows being swept from left to right.
I was wondering if it's possible to control the animation so that the hiding/showing of rows look like when you turn on/off Wi-Fi from Settings on the phone.
Thanks.
You can override this insertAnimation(forSections:) -> UITableViewRowAnimation as you need....
https://github.com/xmartlabs/Eureka/blob/3efe00e9a65a48c8823e7622dcd478efdc78b753/Source/Core/Core.swift#L600
@mtnbarreto This doesn't work for me.
The following is basically my class:
class ViewController: FormViewController {
let firstNameTag = "First Name"
let lastNameTag = "Last Name"
let descriptionTag = "Description"
let hideSomeRow = true
override func viewDidLoad() {
super.viewDidLoad()
form +++
TextRow(firstNameTag).cellSetup { cell, row in
cell.textField.placeholder = row.tag
}
<<< TextRow(lastNameTag).cellSetup { cell, row in
cell.textField.placeholder = row.tag
// conditionally hide row
self.tableView?.beginUpdates()
row.hidden = Condition(booleanLiteral: self.hideSomeRow)
row.evaluateHidden()
self.tableView?.endUpdates()
}
}
override func insertAnimation(forRows rows: [BaseRow]) -> UITableViewRowAnimation {
return .none
}
}
Any input?
There are multiple functions you can override to avoid animations.
override func insertAnimation(forRows rows: [BaseRow]) -> UITableViewRowAnimation {
return .none
}
override func deleteAnimation(forRows rows: [BaseRow]) -> UITableViewRowAnimation {
return .none
}
override func reloadAnimation(oldRows: [BaseRow], newRows: [BaseRow]) -> UITableViewRowAnimation {
return .none
}
override func insertAnimation(forSections sections: [Section]) -> UITableViewRowAnimation {
return .none
}
override func deleteAnimation(forSections sections: [Section]) -> UITableViewRowAnimation {
return .none
}
override func reloadAnimation(oldSections: [Section], newSections: [Section]) -> UITableViewRowAnimation {
return .none
}
@SebastianBoldt I tried your suggestion, however there still appears to be an animation whenever insertion or deletion occurs.
@damiancesar Is the object you've added those methods to the delegate of your form?
(Using FormViewController makes the view controller automagically be the delegate of self.form. I've added those lines to my subclass of FormViewController and it's working for me.)
still not working
self.form.removeAll()
form
+++ Section("Account")
<<< LabelRow(){ row in
row.title = "Email"
}
<<< LabelRow(){ row in
row.title = "Logout"
}
+++ Section("App")
<<< LabelRow(){ row in
row.title = "Terms & Conditions"
}
<<< LabelRow(){ row in
row.title = "Privacy Policy"
}
<<< LabelRow(){ row in
row.title = "About"
row.onCellSelection({ (cellOf, row) in
self.performSegue(withIdentifier: "AboutSegue", sender: self)
})
}
@radvansky-tomas Have a look at #1592
We can disable all animations by this
UIView.setAnimationsEnabled(false)
Most helpful comment
There are multiple functions you can override to avoid animations.