Reputation: 61
I am trying to add a calendar event using EKEventEditViewController
. I have setup a EKEventEditViewController
properly with an EKEventStore
, EKEvent
, and its editViewDelegate
as the presenting view controller. The EKEventEditViewController
presents itself correctly, but when I press either 'add' or 'cancel', didCompleteWithAction
does not called in EKEventEditViewDelegate
. But, I do get this error (no crash though):
[EKCalendarItemLocationInlineEditItem isSubitemAtIndexSaveable:] - Location Inline Edit Item didn't have a text label on its non conference location cell; will return NO
You can see here that EKCalendarItemLocationInlineEditItem
is in the EventKitUI
framework.
It seems like this has something to do with location but I can't seem to figure it out. Has anyone ever encountered this error, or have any tips on how to further debug? Thanks! I am running iOS 11 and Xcode 9.0.1.
Upvotes: 6
Views: 2049
Reputation: 9730
Most probably, the issue is that you don't dismiss their view controller when the delegate gets called:
func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction) {
controller.dismiss(animated: true)
}
Implement this method to dismiss the modal event edit view controller.
Upvotes: 0
Reputation: 1109
If you already have set your delegate and are still hitting the dreaded [EventEditor] -[EKCalendarItemLocationInlineEditItem isSubitemAtIndexSaveable:] - Location Inline Edit Item didn't have a text label on its non conference location cell; will return NO
, you probably haven't set EKEventEditViewController.eventStore
.
Here is a working sample code showing how to configure properly EKEventEditViewController
:
func showNewEvent(askPermission: Bool) {
let store = EKEventStore()
if askPermission {
store.requestAccess(to: .event) { (granted, error) in
if granted {
DispatchQueue.main.async {
self.showNewEvent(askPermission: false)
}
}
}
return
}
let event = EKEvent(eventStore: store)
event.title = "New event name"
event.notes = "Some notes"
event.availability = .busy
event.isAllDay = ...
event.startDate = ...
event.endDate = ...
event.structuredLocation = ...
let vc = EKEventEditViewController()
vc.event = event
vc.eventStore = store // <-- this needs to be the same event store you used for EKEvent
vc.editViewDelegate = self
present(vc, animated: true, completion: nil)
}
This code is inspired by this amazing post https://dev.to/nemecek_f/how-to-use-ekeventeditviewcontroller-in-swift-to-let-user-save-event-to-ios-calendar-d8
Upvotes: 0
Reputation: 1140
It looks like you did not set the editViewDelegate
before presenting the EKEventEditViewController
. Without the delegate, the Buttons 'add' and 'cancel' do not respond.
Creating the EventView and presenting (Swift)
let eventView: EKEventEditViewController = EKEventEditViewController()
eventView.event = event
eventView.editViewDelegate = self
eventView.eventStore = eventStore
present(eventView, animated: true) { }
ObjC
EKEventEditViewController *eventView = [[EKEventEditViewController alloc] init];
eventView.event = event;
eventView.editViewDelegate = self;
eventView.eventStore = eventStore;
[self presentViewController:eventView animated:true completion: nil];
Upvotes: 2