开发者

Multi-day event in iPhone calendar

I want to add an event but the event is added in all the days. If I add an event which has a last date after 10 days, then the event is added today and all the days between today and 10 days from now. I want to just add the event at the end date, not between these days. How can I do this?

EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
event.title     = appDelegate.Name开发者_开发技巧;
event.startDate = [[NSDate alloc] init];
event.endDate   = appDelegate.Date_iCal;
//event.allDay    = NO;
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];


you have to specify the correct start date.

Right now you do this

event.startDate = [[NSDate alloc] init]; // today
event.endDate   = appDelegate.Date_iCal; // in the future

and this will obviously add an event that starts now and ends somewhere in the future.

I don't know anything about your event, so you have to figure out the start and end of it on your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜