我试图让它像这样工作:
class CalendarViewController: DayViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "CalendarKit Demo"
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Dark",
style: .done,
target: self,
action: #selector(changeStyle))
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Change Date",
style: .plain,
target: self,
action: #selector(presentDatePicker))
navigationController?.navigationBar.isTranslucent = false
dayView.autoScrollToFirstEvent = true
reloadData()
}
@objc func changeStyle() {
print("clicked change style")
}
@objc func presentDatePicker() {
print("clicked date picker")
}
override func eventsForDate(_ date: Date) -> [EventDescriptor] {
let models = [Happening(startDate: Date(), endDate: Date(timeInterval: 3600, since: Date()), title: "Test Event", location: "on mother earth")]
var events = [Event]()
for model in models {
let event = Event()
event.startDate = model.startDate
event.endDate = model.endDate
let info = [model.title, model.location]
event.text = info.reduce("", {$0 + $1 + "\n"})
events.append(event)
}
return events
}
}
struct Happening {
let startDate: Date
let endDate: Date
let title: String
let location: String
init (startDate: Date, endDate: Date, title: String, location: String) {
self.startDate = startDate
self.endDate = endDate
self.title = title
self.location = location
}
}
日历显示,但我既没有得到标题也没有导航项目。对我来说看起来像这样:
我在这里做错了什么?非常感谢您的帮助!
侧面的问题:尚未弄清楚如何(或者如果可能的话)在界面构建器中使用它,例如在将其集成到另一个应用程序时在顶部添加自定义导航元素。那可能吗?