TimelineTableViewCell
TimelineTableViewCell copied to clipboard
maxNumSubviews == -1
Not sure how to reproduce this, but for some reason maxNumSubviews ends up being -1, which causes a crash in TimelineTableViewCell on this line:
let views = viewsInStackView.count <= maxNumSubviews ? viewsInStackView : Array(viewsInStackView[0..<maxNumSubviews])
Just curious if anyone else has had this problem? I'm working on a fork on my end, so it may be caused by that. However refactoring this line to be a bit cleaner couldn't hurt
Yeah, I think it's fork specific, as in the definition
Int(floor(stackView.frame.size.width / (stackView.frame.size.height + stackView.spacing))) - 1
the ratio is evaluated to 0, which is then turned to -1.
Thoughts on submitting a fix?
@peterkos thank your for reporting this issue. It should be checked whether maxNumSubviews and divisor are valid or not. I will try to fix it when I am available. BTW, I would appreciate it if you can help fix it or provide reproduce test cases.
I'm busy through the weekend, so I wont' be able to investigate further until then. But here's my temporary fix:
+ var views = viewsInStackView
+ // Overwrite if too many views
+ if (viewsInStackView.count > maxNumSubviews && maxNumSubviews >= 0) {
+ views = Array(viewsInStackView[0..<maxNumSubviews])
+ }
Same here