【问题标题】:how to programmatically select the date/time and title for Event Kit calendar如何以编程方式选择 Event Kit 日历的日期/时间和标题
【发布时间】:2012-03-05 23:19:19
【问题描述】:

下面是我的代码。当前在按钮上单击它会打开日历,以便用户可以添加事件。当活动日历打开时,如何为用户传递或预选日期和标题?

这是我的代码。

 -(IBAction) createEvent{
EKEventStore *eventStore = [[EKEventStore alloc] init];

EKEventEditViewController * controller =[[EKEventEditViewController alloc] init];
controller.eventStore = eventStore;
controller.editViewDelegate = self;
[self presentModalViewController: controller animated:YES]'



}

-(void) eventEditViewController:(EKEventEditViewController *) controller didCompleteWithAction:(EKEventEditViewAction)action{
[self dismissModalViewControllerAnimated:YES];
}

【问题讨论】:

    标签: xcode eventkit


    【解决方案1】:

    您需要为 EKEventEditViewController 分配一个事件。您将您的详细信息填写到事件对象中。

    EKEventStore *store = [[EKEventStore alloc] init];
    EKEvent *event = [store eventWithIdentifier:@"some identifier"];
    if(!event)
    {
        event = [EKEvent eventWithEventStore:store];
        event.startDate = someDate;
        event.endDate = someEndDate;
        event.location = someLocationString;
        event.availability = EKEventAvailabilityBusy;
        event.title = @"Title here";
    }
    EKEventEditViewController *ekVC = [[EKEventEditViewController alloc] init];
    ekVC.event = event;
    ekVC.editViewDelegate = self;
    [self presentModalViewController:ekVC animated:YES];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-11
      • 2020-04-23
      • 1970-01-01
      相关资源
      最近更新 更多