Мне кажется, что этот календарь настроен программно, я также добавил жест панорамирования для изменения области, но когда я меняю область с недели на месяц, приложение вылетает; Я добавил делегата и источник данных, но теперь я не знаю, как решить эту проблему sh.
import UIKit
import FSCalendar
class Calendar_ViewController: UIViewController {
//MARK: - UIElements Creation
lazy var calendarView : FSCalendar = {
let calendar = FSCalendar()
calendar.frame = CGRect(x: 0, y: 30, width: view.frame.width, height: view.frame.height/2)
calendar.translatesAutoresizingMaskIntoConstraints = false
return calendar
}()
fileprivate lazy var scopeGesture: UIPanGestureRecognizer = {
[unowned self] in
let panGesture = UIPanGestureRecognizer(target: self.calendarView, action: #selector(self.calendarView.handleScopeGesture(_:)))
panGesture.minimumNumberOfTouches = 1
panGesture.maximumNumberOfTouches = 2
return panGesture
}()
//MARK: - Local Variables and Consts
var userInterfaceStyle : UIUserInterfaceStyle?
//MARK: - View Functions
override func viewDidLoad() {
super.viewDidLoad()
userInterfaceStyle = traitCollection.userInterfaceStyle //Dark Mode Support
self.navigationItem.title = "Calendario"
view.backgroundColor = backgroundDarkMode
view.addGestureRecognizer(scopeGesture)
view.addSubview(calendarView)
calendarView.delegate = self
calendarView.dataSource = self
constrainCalendarView()
calendarView.register(FSCalendarCell.self, forCellReuseIdentifier: "cell")
}
//MARK: - Various Functions
//MARK: - Constrain Functions
private func constrainCalendarView() {
calendarView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
calendarView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
calendarView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
calendarView.bottomAnchor.constraint(lessThanOrEqualTo: view.centerYAnchor).isActive = true
}
}
extension Calendar_ViewController : FSCalendarDelegate, FSCalendarDataSource {
}
, и это ошибка:
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [207 nan].