During form setup
form +++ Section() { section in
var header = HeaderFooterView(title: "")
header?.height = { 1 }
section.header = header
var footer = HeaderFooterView(title: "")
footer?.height = { 1 }
section.footer = footer
}
it displayWith animation of insert Section
public func insertAnimationForSections(sections: [Section]) -> UITableViewRowAnimation {
return .Automatic
}
It looks weird on first load, also the same thing is not called for Rows. Any idea to disable animation on first load?
Well well well
use
form = Section()
instead of
form +++ Section()
but please update the Doc. see this
https://github.com/xmartlabs/Eureka#how-to-create-a-form
For this issue, I have first tried to override related methods as followed but it did not disable the animation at all since .None does not mean "no animation" and it just sets the animation to default one.
override func insertAnimationForRows(rows: [BaseRow]) -> UITableViewRowAnimation {
return .None
}
override func insertAnimationForSections(sections: [Section]) -> UITableViewRowAnimation {
return .None
}
My following solution might sound hacky but I was able to get rid of animation at all by disabling animations at the beginning and enabling back again when the whole add section-add row procedure finishes.
private func performWithoutAnimation(closureToPerform: () -> Void) {
UIView.setAnimationsEnabled(false)
closureToPerform()
UIView.setAnimationsEnabled(true)
}
closureToPerform here is clearly the function in which you are building the form by adding sections and rows to it.
Yikes. Is there a better way to do this? I'm seeing table animations when I conditionally hide rows upon first launch.
@mtnbarreto ^^ ?
I'm getting error when using "form = Section()" and have more sections with +++ .
'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (2) must be equal to the number of sections contained in the table view before the update (0), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'
eg:
form = Section()
<<< DateTimeRow("start_date") {
$0.title = "Start Date"
}
+++ Section()
<<< DateTimeRow("end_date") {
$0.title = "End Date"
}
If I use "form +++ Section()" works but with the animation.
I've tried the alikayhan solution and it works fine, but it's a workaround ='(
The issue stills happens to me in the latest version and form = Section() triggers an error. The closure workaround works but like @diegoalex says, its a workaround =/
Can anyone reproduce it?
The workaround works for me! Thanks for pointing me in the right direction. I could even use the default method
UIView.performWithoutAnimation { ...actions... }
Thanks for the workaround. Still, there should be better support for this in the framework, the initial animation looks ugly.
The workaround works for me! Thanks for pointing me in the right direction. I could even use the default method
UIView.performWithoutAnimation { ...actions... }
this worked for me.
When do i use the code?
altough UIView.performwithoutanimation does seems to work it doesnt make sense that it to remove the animations
Most helpful comment
The workaround works for me! Thanks for pointing me in the right direction. I could even use the default method
UIView.performWithoutAnimation { ...actions... }