O'Reilly logo

iOS 5 Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14.9. 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 .h file of our view controller:

#import <UIKit/UIKit.h>
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>

@interface Presenting_Event_View_ControllersViewController
           : UIViewController <EKEventViewDelegate>

@property (nonatomic, strong) EKEventStore *eventStore;

@end

We should now synthesize our eventStore property in the implementation of our view controller:

#import "Presenting_Event_View_ControllersViewController.h" @implementation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required