Calendar Interface

The graphical interface consists of two views for letting the user work with an event:

EKEventViewController
Shows the description of a single event, possibly editable.
EKEventEditViewController
Allows the user to create or edit an event.

EKEventViewController simply shows the little rounded rectangle containing the event’s title, date, and time, familiar from the Calendar app, possibly with additional rounded rectangles describing alarms and notes. The user can’t tap these to do anything. To use EKEventViewController, instantiate it, give it an event, and push it onto the stack of an existing UINavigationController. The user’s only way out will be the Back button. So, for example:

EKEventViewController* evc = [[EKEventViewController alloc] init];
evc.event = [marr objectAtIndex:0];
evc.allowsEditing = NO;
[self.navigationController pushViewController:evc animated:YES];
[evc release];

The documentation says that allowsEditing is NO by default, but in my testing the default was YES; perhaps you’d best play safe and set it regardless. If it is YES, an Edit button appears as the right bar button item in the navigation bar, and by tapping this, the user can edit the various aspects of an event in the same navigation interface that should be familiar from the Calendar app, including the large red Delete button at the bottom. If the user ultimately deletes the event or edits it and taps Done, the change is saved into the database.

Starting in iOS 4.2, you can assign ...

Get Programming iOS 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.