我JTAppleCalendar在我的项目中添加了一些标签,我想在我的一些日历单元格中添加一些标签。我成功添加了它们,但是当我在日历月份向左或向右滚动时,标签内的单元格消失、隐藏或混合,并且当我一次又一次滚动时,混合越来越多。我需要任何协议或代表等吗?或者,这只是一个错误?
我该如何修复该错误?
我的cellForItemAt代码:
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableCell(withReuseIdentifier: "CellView", for: indexPath) as! CellView
var currentdate = String(describing: myCalendar.date(byAdding: .day, value: 1, to: cellState.date))
currentdate = currentdate.substring(from: 9, length: 10)
cell.tagList.tags.removeAll()
cell.tagList.hide()
cell.contentView.backgroundColor = nil
cell.tagList.alpha = 0
cell.tagList.numberOfRows = 0
cell.tagList.backgroundColor = UIColor.clear
cell.tagList.isHidden = true
var i : Int
i = 0
for object in datas {
i = …Run Code Online (Sandbox Code Playgroud) 我在尝试从 patchthecode 的教程中重新创建日历时遇到了一些问题 这是链接:https ://patchthecode.github.io/MainTutorial2/ 。以下是我遇到的一些错误:
1.无法将“ViewController”类型的值分配给“UICollectionViewDataSource”类型?
2.无法将“ViewController”类型的值分配给“UICollectionViewDelegate”类型?
3.“JTAppleCalendarView?”类型的值 没有成员“registerCellViewXib”
4.“JTAppleCalendarView?”类型的值 没有成员“cellInset”
5.未声明类型'DateCell'的使用
6.'calendar(_:cellForItemAt:cellState:indexPath:)'的无效重新声明
7.使用未解析的标识符“myCustomCell”
import UIKit
import JTAppleCalendar
class ViewController: UIViewController {
let white = UIColor.white
let darkPurple = UIColor.purple
let dimPurple = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)
@IBOutlet weak var calendarView: JTAppleCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
calendarView.dataSource = self
calendarView.delegate = self
calendarView.registerCellViewXib(file: "CellView") // Registering your cell is …Run Code Online (Sandbox Code Playgroud) 我在 iOS 应用程序中使用 JTAppleCalendar,但我发现很难实现像传统日历通常那样在日历顶部显示月份和年份的标题。我已按照文档中的说明进行操作,但尽管我设法添加“标题”来显示一周中的几天,但我仍然发现这很困难,尽管我觉得可能不正确。对于以前实现过这个库的人来说,我可以获得一些如何做到这一点的帮助吗?或者也许您使用过的另一个日历有更简单的方法来完成此任务?
文档: https: //patchthecode.github.io/Headers/
我这样实现一周中的几天:
// This sets the height of your header
func calendar(_ calendar: JTAppleCalendarView, sectionHeaderSizeFor range: (start: Date, end: Date), belongingTo month: Int) -> CGSize {
return CGSize(width: 200, height: 50)
}
// This setups the display of your header
func calendar(_ calendar: JTAppleCalendarView, willDisplaySectionHeader header: JTAppleHeaderView, range: (start: Date, end: Date), identifier: String) {
let headerCell = (header as? PinkSectionHeaderView)
headerCell?.title.text = "S M T W T F S"
}
Run Code Online (Sandbox Code Playgroud) 我在尝试加载项目时收到此错误消息
由于未捕获的异常'NSInternalInconsistencyException'而终止app,原因:'无法使类型的视图出列:具有标识符CustomCell的UICollectionElementKindCell - 必须为标识符注册nib或类或在故事板中连接原型单元'
我的代码是:
extension ViewController: JTAppleCalendarViewDelegate, JTAppleCalendarViewDataSource {
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
formatter.dateFormat = "yyyy MM dd"
formatter.timeZone = Calendar.current.timeZone
formatter.locale = Calendar.current.locale
let startDate = formatter.date(from: "2017 01 01")!
let endDate = formatter.date(from: "2017 12 31")!
let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate)
return parameters
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "CustomCell", for: indexPath) as! CustomCell
cell.dateLabel.text = cellState.text
return cell …Run Code Online (Sandbox Code Playgroud) 我正在使用 JTAppleCalendar,每个月的日期都比应有的提前 1 天。这是我的配置代码:
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
formatter.dateFormat = "yyyy MM dd"
formatter.timeZone = Calendar.current.timeZone
formatter.locale = Calendar.current.locale
let currentYear = Calendar.current.component(.year, from: Date())
let stringCurrentYear = String(currentYear)
let nextYear = currentYear + 1
let stringNextYear = String(nextYear)
let currentMonth = Calendar.current.component(.month, from: Date())
let stringCurrentMonth = String(currentMonth)
let startDate = formatter.date(from: "\(stringCurrentYear) \(stringCurrentMonth) 01")!
let endDate = formatter.date(from: "\(stringNextYear) 12 31")!
let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate)
return parameters
}
Run Code Online (Sandbox Code Playgroud)
这是当前的输出:
2018 年 1 …