어떻게 사용자의 캘린더에 일정을 추가 하나 사용자가 캘린더 등을 선택할 수있게합니까?이 코드는 작동하지만 사용자의 기본 캘린더에 이벤트를 추가합니다. 사용자가 캘린더를 변경하고 알림을 사용자 정의하는 것을 허용하려면 어떻게합니까? 다른 앱이 캘린더 앱을 열고 필드를 미리 채우는 것을 보았습니다.이벤트를 사용자의 캘린더에 저장하십시오.
//add to calendar
let eventStore : EKEventStore = EKEventStore()
eventStore.requestAccessToEntityType(EKEntityType.Event, completion: { (granted, error) in
if granted && error == nil {
let event:EKEvent = EKEvent(eventStore: eventStore)
event.title = "My event: " + self.event.name
event.startDate = self.event.startTime
event.endDate = self.event.endTime
event.notes = self.event.description
event.calendar = eventStore.defaultCalendarForNewEvents
do {
try eventStore.saveEvent(event, span: .ThisEvent, commit: true)
self.dismissViewControllerAnimated(true, completion: {})
} catch {
self.dismissViewControllerAnimated(true, completion: {})
}
} else {
self.dismissViewControllerAnimated(true, completion: {})
}
})
완벽한을, 당신의
Info.plist
에NSCalendarsUsageDescription
를 공급 한 것으로 가정 정확히 나는 찾고 있었다. 캘린더 옵션 (저장할 캘린더 선택)은 모달보기에 표시됩니다. 내가 그 옵션을 어떻게 보이게 할 수 있는지 알고 있니? – Prabhu"그 옵션을 보이게"하는 것이 무슨 뜻인지 확실하지 않습니다. 기기에 여러 개의 캘린더가있는 경우 이벤트의 속성으로 표시됩니다. 사용자가 여러 개의 캘린더를 가지고 있지 않은 경우, 그렇지 않습니다. 아니면 여러 개의 캘린더가 있고 편집/추가/취소를 위해 이벤트가 사용자에게 표시 될 때 캘린더 옵션을 보지 못하는 장치가 있다고 말하는 것입니까? – Rob
제 잘못입니다. 나는 시뮬레이터에서 테스트를하고 있었다. 기기에서 테스트했을 때 괜찮습니다. – Prabhu