【问题标题】:Open "Event Details" in calendar app with specific event id在具有特定事件 ID 的日历应用中打开“事件详细信息”
【发布时间】:2016-10-04 06:58:34
【问题描述】:

我正在尝试打开带有特定事件的日历,我以编程方式添加了事件,并且这些事件的所有 ID 都是持久的。

这就是我添加事件的方式

-(IBAction)addEvent:(id)sender{
    EKEventStore *store = [[EKEventStore alloc]init];
    [store requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
        if (!granted) { return; }
        EKEvent *event = [EKEvent eventWithEventStore:store];
        event.title = @"Demo Title";
        NSDateComponents *comps=[[NSDateComponents alloc]init];
        [comps setDay:4];
        [comps setMonth:10];
        [comps setYear:2016];
        [comps setHour:12];
        [comps setMinute:1];

        NSDate *date=[[[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian] dateFromComponents:comps];
        _date=date;
        event.startDate = date;
        event.endDate=date;
        event.notes=@"This is event description";

        EKAlarm *alarm=[EKAlarm alarmWithAbsoluteDate:date];
        [event addAlarm:alarm];
        event.calendar = [store defaultCalendarForNewEvents];

        NSError *err=nil;
        [store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
    }];
}

事件添加成功,我也可以打开日历应用程序,但问题是我无法在日历中的事件详细信息中导航

这是我打开日历的方法

-(IBAction)openCalender:(id)sender{
    NSInteger interval = [_date timeIntervalSinceReferenceDate];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"calshow:%ld?eventid=%@", (long)interval,_eventID]];
    NSLog(@"%@",url);
    [[UIApplication sharedApplication] openURL:url];
}

我想要的是下面的截图

我得到的是

有什么想法吗?

【问题讨论】:

  • 运气好可以让它工作吗?
  • 不,@AhmedW 我没有

标签: ios objective-c iphone ekeventkit


【解决方案1】:

要回答我自己的问题,任何公共 API 都无法做到这一点

我搜索了一年多,但任何公共 API 都无法做到这一点,但我想可能有一些私有 API 可以做到这一点(并且可能这样做会让我们的应用程序被拒绝)。

日历应用程序的小部件正在做我想做的事情,但 Apple 的 API 不允许我们使用它。哈哈

【讨论】:

    【解决方案2】:

    我真的不认为有办法做到这一点。即使从默认邮件应用程序创建新日历事件也会打开日历日视图。如果这个功能是可能的,我相信他们至少会在默认邮件应用程序中实现它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-14
      • 2023-01-10
      • 2019-07-30
      相关资源
      最近更新 更多