2014-10-29 58 views
0

我使用下面的代碼爲過去events.Please告訴我過去的活動過去的事件不能顯示在日曆編程

NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]]; 
NSPredicate *fetchCalendarEvents = [store predicateForEventsWithStartDate:[NSDate distantPast] endDate:endDate calendars:nil]; 
NSArray *eventList = [store eventsMatchingPredicate:fetchCalendarEvents]; 
NSLog(@"allevent:%@",eventList); 
+0

請告訴我解決方案 – 2014-10-30 01:11:14

回答

0

解決方案只需按照下面的代碼

NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]]; 

    NSArray *calendarArray = [NSArray arrayWithObject:cal]; 

    NSPredicate *fetchCalendarEvents = [eventStore predicateForEventsWithStartDate:[NSDate date] endDate:endDate calendars:calendarArray]; 

    NSArray *eventList = [eventStore eventsMatchingPredicate:fetchCalendarEvents]; 

    for(int i=0; i < eventList.count; i++) 
    { 

    NSLog(@"Event Title:%@", [[eventList objectAtIndex:i] title]); 

    } 
+0

不工作。請告訴我不同​​的解決方案 – 2014-10-30 01:04:29

+0

如果你使用這個,你會得到什麼輸出? – user3182143 2014-10-30 05:19:34

+0

只有將來的事件顯示。但過去的事件無法顯示 – 2014-10-31 02:16:30