如何从我的应用程序更新EventKit添加事件标题?

时间:2011-06-15 14:02:39

标签: iphone objective-c xcode4

我从rss feed获取数据,其中我获得了标题,日期和urllink我在tableView中显示标题和日期,并在detailView中显示urllink。 在这个详细视图中,我给出了UIBarButton

UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bell.png" ] style:UIBarButtonItemStylePlain target:self action:@selector(addEvent:)];

addEvent方法用于提供EventKit选项......

-(IBAction) addEvent:(id)sender {

EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];
addController.eventStore = self.eventStore;
[self presentModalViewController:addController animated:YES];

addController.editViewDelegate = self;
[addController release];
}

点击此addButtonItem后,我们在此屏幕中显示Add Event屏幕第一个选项是Title and Location我想更新这个“Title”选项,我的数据来自RssFeed。

enter image description here

如何使用我的RSSFeed标题数据从我的应用程序更新此内容我应该在哪里进行更改...

先谢谢。

1 个答案:

答案 0 :(得分:2)

您实际上是正确的...但是EKEventViewController对象有一个事件属性,您可以使用它来设置所需的所有属性。使用所需的属性,开始时间,结束时间,标题等创建事件,并在显示之前设置EKEventViewController的event属性。

    EKEventStore *eventStore = [[EKEventStore alloc] init];

    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     = @"Whatever you want your title to be";

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    event.startDate = [NSDate date]; // or however you are setting your start date
    event.endDate   = [NSDate dateWithTimeInterval:600 sinceDate:event.startDate];
    event.allDay    = YES; // or NO

    EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];
    addController.event = event;
    addController.eventStore = eventStore;
    addController.editViewDelegate = self;

    [self presentModalViewController:addController animated:YES];