diff --git a/KVKCalendar.podspec b/KVKCalendar.podspec index 07bdb126..0d533a5e 100644 --- a/KVKCalendar.podspec +++ b/KVKCalendar.podspec @@ -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 diff --git a/Sources/KVKCalendar/MonthView.swift b/Sources/KVKCalendar/MonthView.swift index 6c3a0a7d..02a632f4 100644 --- a/Sources/KVKCalendar/MonthView.swift +++ b/Sources/KVKCalendar/MonthView.swift @@ -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 @@ -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) }