JTAppleCalendar
JTAppleCalendar copied to clipboard
Crash when creating cell extending JTACMonthCell programatically
**(Required) Version Number: 8.0.2
Description
Showing year view crash with assert error:
guard let monthView = monthView else { assert(false); return }
Steps To Reproduce
Creating month cell by extending JTACMonthCell programatically.
Expected Behavior
Code should pass assert false
Additional Context
By programatically creating month cell, there's no way to access var monthView: JTACCellMonthView?
in parent class.
Making it public and assigning from child will fix the error.
Thanks. Year view still has some edgecases to work out. Thanks for letting me know this. Will take a look over the weekend once free. I have some other issues on the issue list looking at, but if this fix is as easy as it sounds, i'll have a look.
@patchthecode any update regarding this issue?
@joshuaLareta fixed by connecting the monthView
outlet from JTACMonthCell
to the JTACCellMonthView
view in my xib.
I ran into this as well. I think the simplest solution if you want to create a JTACMonthCell programatically is to change the accessibility modifier in the class to open, e.g.
open class JTACMonthCell: UICollectionViewCell {
@IBOutlet open var monthView: JTACCellMonthView?
weak open var delegate: JTACCellMonthViewDelegate?
This allow a subclass to create the instance of JTACCellMonthView in code (so does not require xib/storyboard) as follows and everything then works, at least in my app.
@patchthecode you open to a PR for this?
override init(frame: CGRect) {
super.init(frame: frame)
monthView = JTACCellMonthView()