Open DigitalVanilla opened 1 year ago
A note: if I extend a UITableViewCell, the problem occur and scrolling seems to fix this, but if I extend a UIView the problem does not appear, so something is in the UITableViewCell class extension that interfere the first time the section is attach.
So you mean this only appears when you subclass UITableViewCell? Are you doing that with your header view class (aka EKHeaderClass)? That should not subclass from UITableViewCell. Subclassing from UIView is correct
So you mean this only appears when you subclass UITableViewCell? Yes I wanted to reuse a row class
Are you doing that with your header view class (aka EKHeaderClass) Yes
Subclassing from UIView is correct But the cell is visible initially and I see that it disappear when the row animation ends, and why scrolling shows it back? Can I load a xib file and then assign the .contentview to the section.header? I wish to be clever and reuse the rows we have created for both rows and headers, in this way we have less classes to maintain.
Have you tried using UITableViewCell subclasses as headers of a UITableView without Eureka? I wouldn't be surprised if there is some added logic in UITableViewCell that is responsible for this.
What I would do in such a case is design a UIView with common design and use that inside both a row and a header, instead of trying to use a cell as header, but maybe it works
Yes, I did use subclassing the headers without having problems. At the moment I cannot put more time and money on this update to use a UIView custom class inside the headers, I wanted to re-use Eureka Custom Class (not the row) to be clever and have one class that does both things (header and regular row). But the point is that the this "glitch" occur only when the section is added, but when the header is off screen and then re enter the screen scrolling back the correct Y position, the cell is visible again; many people have this problem, is possible to track it someway?
Describe the bug I wish to re-use a custom class with a xib file in a section with some rows added dynamically, but when I use the following code
var section = Section() { section in section.tag = v var header = HeaderFooterView<EKHeaderClass>(.nibFile(name: "EKHeader", bundle: nil)) header.height = { 25 } header.onSetupView = { view, _ in view.titleLabel.text = "My title" view.subTitleLabel.isHidden = "My subtitle" } section.header = header } section.insert(contentsOf: [rowA, rowB], at: 0) form.insert(section, at: mealParts.count)
I see that the xib view and its class gets instantiated but it disappear immediately; if I keep adding more of the same to have a very long table/form and i start to scroll, the headers reappear without problems. On the contrary, if I use a simple view class, I have no problems and I see the header being attach and never disappear. Does anyone knows how to fix this?
Thanks 1k
Versions (please complete the following information):
- Device: iPhone 12
- OS: 15.0
- Eureka Version 5.4.0
- Xcode version 14.1
How is the behavior in this assignment (inside the onSetupView block):
view.subTitleLabel.isHidden = "My subtitle"
I created this ViewController, with the custom header subclassing UITableViewCell. I could not reproduced the issue.
import UIKit
import Eureka
class ViewController: FormViewController {
override func viewDidLoad() {
super.viewDidLoad()
for _ in 0...19 {
createSection()
}
}
private func createSection() {
var section = Section() { section in
var header = HeaderFooterView<EKHeaderClass>(.nibFile(name: "EKHeader", bundle: nil))
header.height = { 25 }
header.onSetupView = { view, _ in
view.titleLabel.text = "My title"
}
section.header = header
}
let rowA = LabelRow() {
$0.title = "Row A!!!"
}
let rowB = LabelRow() {
$0.title = "Row B!!!"
}
section.insert(contentsOf: [rowA, rowB], at: 0)
form.insert(section, at: 0)
}
}
class EKHeaderClass: UITableViewCell {
@IBOutlet var titleLabel: UILabel!
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
Versions:
Device: iPhone 14 Pro iOS: 16.1 (20B72) Eureka Version 5.4.0 Xcode version 14.1 (14B47b)
How is the behavior in this assignment (inside the onSetupView block):
view.subTitleLabel.isHidden = "My subtitle"
I have a stackview vertical and when there is only the title I hide the subtitle
Ok, so is possible to use a custom tableviewcell instead of a view, good to know.
Ok, I was testing it and I found out that if I delay the creation of the sections with the custom header form a nib, it does not works. Please add this to your code:
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
for _ in 0...19 {
self.createSection()
}
}
Describe the bug I wish to re-use a custom class with a xib file in a section with some rows added dynamically, but when I use the following code
I see that the xib view and its class gets instantiated but it disappear immediately; if I keep adding more of the same to have a very long table/form and i start to scroll, the headers reappear without problems. On the contrary, if I use a simple view class, I have no problems and I see the header being attach and never disappear. Does anyone knows how to fix this?
Thanks 1k
Versions (please complete the following information):