Skip to content

Commit

Permalink
Merge pull request #313 from kvyatkovskys/feature/v_0.6.14
Browse files Browse the repository at this point in the history
Fixed the crash in MonthView when we try to scroll to section
  • Loading branch information
kvyatkovskys authored May 6, 2023
2 parents a24b261 + 0003639 commit 1d89fcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion KVKCalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'KVKCalendar'
s.version = '0.6.13'
s.version = '0.6.14'
s.summary = 'A most fully customization calendar for Apple platforms.'

s.description = <<-DESC
Expand Down
7 changes: 6 additions & 1 deletion Sources/KVKCalendar/MonthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ final class MonthView: UIView {
// to check when the calendarView is displayed on superview
guard superview?.superview != nil && collectionView?.dataSource != nil else { return }

DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self] in
guard let self = self else { return }

if let attributes = self.collectionView?.layoutAttributesForSupplementaryElement(ofKind: UICollectionView.elementKindSectionHeader, at: IndexPath(row: 0, section: idx)),
let inset = self.collectionView?.contentInset {
let contentOffset: CGPoint
Expand All @@ -127,6 +129,9 @@ final class MonthView: UIView {
}
self.collectionView?.setContentOffset(contentOffset, animated: animated)
} else {
let index = IndexPath(row: 0, section: idx)
guard self.parameters.monthData.days[index] != nil else { return }

let scrollType: UICollectionView.ScrollPosition = self.style.month.scrollDirection == .horizontal ? .left : .top
self.collectionView?.scrollToItem(at: IndexPath(row: 0, section: idx), at: scrollType, animated: animated)
}
Expand Down

0 comments on commit 1d89fcd

Please sign in to comment.