我找到了从我的应用程序打开日历的示例代码,但我无法在特定日期打开.
NSString* launchUrl = @"calshow://";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: launchUrl]];
Run Code Online (Sandbox Code Playgroud)
有没有办法在"lunchUrl"字符串的末尾添加特定日期,因此当用户打开日历时,它会显示给定的日期.
我已经尝试过以下格式:@"calshow://?= 2013 12 19",@"calshow://?= 2013-12-19",@"calshow://?= 2013 + 12 + 19" .这些似乎都不适合我...任何想法我在做错什么?
我正在尝试使用特定事件打开日历,我已经以编程方式添加了事件,并且这些事件的所有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];
}];
}
Run Code Online (Sandbox Code Playgroud)
该事件已成功添加,我也可以打开日历应用程序但事情是我无法在日历中的事件详细信息中导航
这是我打开日历的方式
-(IBAction)openCalender:(id)sender{
NSInteger interval = [_date …Run Code Online (Sandbox Code Playgroud) 我可以启动谷歌地图,邮件,Safari和其他......但是日历有相同的功能吗?
编辑:我只想在日历中添加一个事件.
多谢你们!
缺口.
calendar ×2
iphone ×2
objective-c ×2
cocoa-touch ×1
ekeventkit ×1
icalendar ×1
ios ×1
shortcut ×1