
I've discovered a really weird corner case. The first time a user select a range on JTAppleCalender the .left cell is separated from the others, but only on the first range selection of the view. All other selections after that display correctly. I've pasted my cell refresh code and a .gif demonstrating the issue
```Swift
@IBAction func clearAllButtonPressed(_ sender: Any) {
arrivalDateLabel.text = "Arrival Date"
departureDateLabel.text = "Departure Date"
calendarView.deselectAllDates(triggerSelectionDelegate: false)
calendarView.reloadData()
}
// Function to handle the calendar selection
func handleSelection(cell: JTAppleCell?, cellState: CellState) {
guard let calendarCellView = cell as? CalendarCellView else {
return
}
//Resets all cells for recycling
calendarCellView.selectedView.isHidden = true
calendarCellView.selectedView.layer.cornerRadius = 0
calendarCellView.selectedView.backgroundColor = UIColor.white
calendarCellView.selectedView.layer.mask = nil
switch cellState.selectedPosition() {
case .full: //For a standalone cell
calendarCellView.selectedView.isHidden = false
calendarCellView.selectedView.layer.cornerRadius = calendarCellView.selectedView.layer.frame.height/2
case .middle: //For a cell with selected dates to left and right
calendarCellView.selectedView.isHidden = false
case .left: //For a cell on the left end
calendarCellView.selectedView.isHidden = false
generateCurve(viewToRound: calendarCellView.selectedView, corner1:.topLeft, corner2:.bottomLeft)
case .right: //For a cell on the right end
calendarCellView.selectedView.isHidden = false
generateCurve(viewToRound: calendarCellView.selectedView, corner1:.topRight, corner2:.bottomRight)
default: //unselected cell
calendarCellView.selectedView.isHidden = true
}
//Highlights the current date
formatter.dateFormat = "MM/dd/yyyy"
let currentDateString = formatter.string(from: Date())
let cellStateDateString = formatter.string(from: cellState.date)
if currentDateString == cellStateDateString { //Highlight the current day (only if user hasn't picked yet)
calendarCellView.selectedView.layer.cornerRadius = calendarCellView.selectedView.layer.frame.height/2
calendarCellView.selectedView.layer.borderColor = UIColor.white.cgColor
calendarCellView.selectedView.layer.borderWidth = 1
calendarCellView.selectedView.backgroundColor = UIColor.init(displayP3Red: 224, green: 224, blue: 224, alpha: 0.21)
calendarCellView.selectedView.isHidden = false
}
}
func generateCurve(viewToRound: UIView, corner1: UIRectCorner, corner2: UIRectCorner) {
let path = UIBezierPath(roundedRect:viewToRound.bounds,
byRoundingCorners:[corner1, corner2],
cornerRadii: CGSize(width: viewToRound.frame.width/2,
height: viewToRound.frame.height/2))
let maskLayer = CAShapeLayer()
maskLayer.path = path.cgPath
viewToRound.layer.mask = maskLayer
}
For the time being I've got a hack fix (below), just thought you should know of the issue.
```Swift
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let date1 = Date().addingTimeInterval(TimeInterval(606024))
let date2 = Date().addingTimeInterval(TimeInterval(606072))
calendarView.selectDates(from: date1, to: date2)
clearAllButtonPressed(sender: self)
}
will take a look.
@jamesjmtaylor i have updated the code base and have merged it to master branch.
Does this problem still happen?
@patchthecode No. Now my app crashes as soon as the view appears with the error " * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[
Is there a version that I can revert to that will work with how the code was above? This is no bueno not having it work at all.
@jamesjmtaylor this is a simple fix.
I changed the name of one thing before release.
I should have told you about that.
Are you on screenHero?
remember, it technically was on master branch, to i do have some free space to change the names of variables :D
7.0.1 fixed the issue. Thanks!
closing issue