我正在使用日历应用程序,需要在iphone日历中添加多个事件。
我搜索了很多演示,但都不满足我的要求。
我正在附上一张屏幕快照,其中显示了它必须看起来是什么样的并充满事件。
如果有任何知道如何在Iphone应用程序中执行相同操作的人,请帮助我。
我们将不胜感激。 :)
答案 0 :(得分:2)
尝试一下-您只需要设置结束日期
func addEvent() {
let store = EKEventStore()
store.requestAccess(to: .event) {(granted, error) in
if !granted { return }
let event = EKEvent(eventStore: store)
event.title = "Event Title"
event.startDate = Date() //today
/// Add as much long event you want
/// I think this is what you need
event.endDate = event.startDate.addingTimeInterval(60*60)//1 hour long meeting
event.calendar = store.defaultCalendarForNewEvents
do {
try store.save(event, span: .thisEvent, commit: true)
self.savedEventId = event.eventIdentifier //save event id to access this particular event later
} catch {
// Display error to user
}
}
}