0
我想創建的兩個日期之間的事件一樣,2015年10月1日至2015/10/05兩個日期在IOS
我想創建的兩個日期之間的事件一樣,2015年10月1日至2015/10/05兩個日期在IOS
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>
-(void)yourmethodToSaveEvent {
EKEventStore *eventStore = [[EKEventStore alloc] init];
[self checkForEventAuthorization:eventStore completionHandler:^(BOOL granted, NSError *error) {
if (granted) {
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = @"title";
event.startDate = [NSDate date]; // start date
event.endDate = [NSDate date]; // end date ;
event.notes = @"notes";
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
BOOL isSuccess = [eventStore saveEvent:event span:EKSpanThisEvent error:&err];
if(isSuccess) {
NSLog (@"your event saved successfully.");
} else {
NSLog (@"failed.");
}
}
}];
}
-(void)checkForEventAuthorization:(EKEventStore *)eventStore completionHandler:(void (^)(BOOL granted, NSError *error))block {
if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
// iOS 6 and later
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
block (granted,error);
}];
} else {
block (YES,nil);
}
}
請檢查這個鏈接和這個程序添加兩個日期的事件,請幫助我https://github.com/muhku/calendar-ui –
您是否使用之間創建活動創建兩個日期之間的活動'EventKit'框架? – Adeel
你能簡單解釋一下嗎? – Mehul
是的即時通訊使用Eventkit框架 –