19.10. Presenting Event View Controllers
Problem
You want to use the built-in iOS SDK view controllers to display the properties of an event in the Calendar database.
Solution
Create an instance of EKEventViewController and push it into a
navigation controller or present it as a modal view controller on
another view controller.
Discussion
Users of iOS devices are already familiar with the interface they
see on the Calendar application. When they select an event, they can see
that event’s properties and they might be allowed to modify the event.
To present a view to a user using built-in iOS SDK event view
controllers, we can instantiate an object of type EKEventViewController and assign an event of
type EKEvent to its event property.
Once that’s done, we can push the event view controller into our
navigation controller and let iOS take care of the rest.
We want to find an event (any event) in any of the calendars
available on an iOS device, from one year ago to now. We will use
EKEventViewController to present that
event to the user. Here is the declaration of our view
controller:
#import "ViewController.h"#import <EventKit/EventKit.h>#import <EventKitUI/EventKitUI.h>@interfaceViewController()<EKEventViewDelegate>@property(nonatomic,strong)EKEventStore*eventStore;@end@implementationViewController
Now in the viewDidAppear:
method of our view controller, let’s go ahead and display the instance
of EKEventViewController on the first event we find in any of the calendars on the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access