How can I display the details of an EKEvent prompt in my application using the EKEventViewController?

EXECUTIVE SUMMARY

I want users of my application to be able to accept / decline an invitation to an event on their calendar. To do this, I try to open the event using the EventKitUI components and allow the user to update the event without leaving my application. The problem is that it resets every time I assign an EKEvent to an EKEventViewController.

DETAILED DESCRIPTION

WHAT I WANT:

To display a similar view similar to that in the native iOS calendar, it should look something like this:

enter image description here

WHAT I HAVE:

import UIKit
import EventKitUI

class CalendarViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDelegate {

   var meetingID = "id"

   override func viewDidLoad() {
       super.viewDidLoad()
       //self.showEditEvent(meeting: meetingID)
       self.showInvite(meeting: meetingID)
   }

   func showInvite(meeting: Meeting){
        let evc = EKEventViewController()
        var event = EKEvent(eventStore: MeetingsFetcher.eventStoreClass)
        event = MeetingsFetcher.eventStoreClass.event(withIdentifier: meetingID)!
        evc.delegate = self 
        evc.event = event
        evc.allowsEditing = true
        evc.allowsCalendarPreview = true
        self.screen.present(evc, animated: true, completion: nil)
    }

    func eventViewController(_ controller: EKEventViewController, didCompleteWith action: EKEventViewAction) {
        controller.dismiss(animated: true, completion: nil)
    }
}

: , EKEvent evc.event, - . , .

evc.event = event

enter image description here

, , EKEventEditViewController(), .

, , , :

    func showEditEvent(meeting: Meeting){
        let evc = EKEventEditViewController()
        evc.eventStore = MeetingsFetcher.eventStoreClass
        var event = EKEvent(eventStore: MeetingsFetcher.eventStoreClass)
        event = MeetingsFetcher.eventStoreClass.event(withIdentifier: meeting.UUID!)!
        evc.event = event
        evc.editViewDelegate = self
        self.screen.present(evc, animated: true, completion: nil)
    }

    func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction) {
        controller.dismiss(animated: true, completion: nil)
    }

enter image description here

+4
1

, , . , info.plist Contacts.

-

enter image description here

+2

Source: https://habr.com/ru/post/1680650/


All Articles