以编程方式设置EKEvent标题

时间:2013-10-11 06:18:44

标签: ios objective-c

我正在尝试打开EKEventStore以在应用中设置提醒。使用以下代码

成功打开
EKEventEditViewController *addController = [[EKEventEditViewController alloc] init];
addController.eventStore = self.eventStore;
addController.editViewDelegate = self;
[self presentViewController:addController animated:YES completion:nil];

但是当我尝试以编程方式添加EKEvent标题时,它不会出现在日历中。

For adding title code is 

EKEvent *addEvent = [EKEvent eventWithEventStore:self.eventStore];
addEvent.title = [NSString stringWithFormat:@"%@", textcontainer.text];

EKReminder *reminder = [EKReminder reminderWithEventStore:eventStore];
reminder.location=@"Ludhiana";

但它不起作用。难道我做错了什么?请帮帮我。

提前致谢。

1 个答案:

答案 0 :(得分:1)

感谢@satheeshwaran查看我的查询。但我通过以下方式解决了这个问题:

EKEvent *addEvent = [EKEvent eventWithEventStore:self.eventStore];
addEvent.title=[NSString stringWithFormat:@"%@", textcontainer.text];
EKEventEditViewController *addController = [[EKEventEditViewController alloc] init];
addController.eventStore = self.eventStore;
addController.event=addEvent;
addController.editViewDelegate = self;
[self presentViewController:addController animated:YES completion:nil];