在具有特定事件 ID 的日历应用程序中打开 "Event Details"
Open "Event Details" in calendar app with specific event id
我正在尝试打开包含特定事件的日历,我以编程方式添加了事件,并且这些事件的所有 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];
}
我要的是下面的截图
我得到的是
有什么想法吗?
我真的不认为有办法做到这一点。即使从默认邮件应用程序创建新的日历事件也会打开日历日视图。如果此功能可行,我相信他们至少会在默认邮件应用程序中实现它。
回答我自己的问题,这对任何 public API
都是不可能的
我搜索了一年多,但任何 public API 都不可能做到这一点,但我想可能会有一些私人 API 来做这个(而且可能这样做会让我们的应用程序被拒绝)。
日历应用程序的小部件与我想做的一样,但 Apple 的 API 不允许我们使用它。哈哈
我正在尝试打开包含特定事件的日历,我以编程方式添加了事件,并且这些事件的所有 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];
}
我要的是下面的截图
我得到的是
有什么想法吗?
我真的不认为有办法做到这一点。即使从默认邮件应用程序创建新的日历事件也会打开日历日视图。如果此功能可行,我相信他们至少会在默认邮件应用程序中实现它。
回答我自己的问题,这对任何 public API
都是不可能的我搜索了一年多,但任何 public API 都不可能做到这一点,但我想可能会有一些私人 API 来做这个(而且可能这样做会让我们的应用程序被拒绝)。
日历应用程序的小部件与我想做的一样,但 Apple 的 API 不允许我们使用它。哈哈