Commit f893e762 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

日历 提醒 优化

parent f2bbc23d
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
- (void)viewDidAppear:(BOOL)animated { - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
// [self.headerView.smartClearButton addRadarAnimation]; [self.headerView.smartClearButton addRadarAnimation];
} }
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
...@@ -371,14 +371,14 @@ ...@@ -371,14 +371,14 @@
break; break;
case 6: case 6:
{ {
if ([ICUserManager shared].isMember) { // if ([ICUserManager shared].isMember) {
ICBatteryCareViewController *vc = [[ICBatteryCareViewController alloc] init]; ICBatteryCareViewController *vc = [[ICBatteryCareViewController alloc] init];
[self.navigationController pushViewController:vc animated:true]; [self.navigationController pushViewController:vc animated:true];
}else { // }else {
ICIAPViewController *iapVC = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICIAPViewController"]; // ICIAPViewController *iapVC = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICIAPViewController"];
ICNavigationController *navc = [[ICNavigationController alloc] initWithRootViewController:iapVC]; // ICNavigationController *navc = [[ICNavigationController alloc] initWithRootViewController:iapVC];
[self presentViewController:navc animated:true completion:nil]; // [self presentViewController:navc animated:true completion:nil];
} // }
} }
break; break;
default: default:
......
...@@ -180,5 +180,4 @@ static ICUserManager * manager; ...@@ -180,5 +180,4 @@ static ICUserManager * manager;
}]; }];
} }
@end @end
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
@interface WMEventCalendarTool() @interface WMEventCalendarTool()
@property (nonatomic ,copy) completion completion; @property (nonatomic ,copy) completion completion;
@property (nonatomic ,copy) completion calendarCompletion;
@property (nonatomic ,copy) completed completed; @property (nonatomic ,copy) completed completed;
@property (nonatomic, strong) EKEventStore *eventStore; @property (nonatomic, strong) EKEventStore *eventStore;
...@@ -34,12 +36,12 @@ ...@@ -34,12 +36,12 @@
- (void)checkCalendarCanUsedCompletion:(completion)completion{ - (void)checkCalendarCanUsedCompletion:(completion)completion{
// EKEntityTypeEvent日历事件 // EKEntityTypeEvent日历事件
// EKEntityTypeReminder提醒事项 // EKEntityTypeReminder提醒事项
self.completion = completion; self.calendarCompletion = completion;
EKAuthorizationStatus eventStatus = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent]; EKAuthorizationStatus eventStatus = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];
if (eventStatus == EKAuthorizationStatusAuthorized) { if (eventStatus == EKAuthorizationStatusAuthorized) {
// 已授权,可使用 // 已授权,可使用
if (self.completion) { if (self.calendarCompletion) {
self.completion(YES, nil); self.calendarCompletion(YES, nil);
} }
}else if(eventStatus == EKAuthorizationStatusNotDetermined){ }else if(eventStatus == EKAuthorizationStatusNotDetermined){
// 未进行授权选择 // 未进行授权选择
...@@ -54,16 +56,16 @@ ...@@ -54,16 +56,16 @@
NSLog(@"用户没有点允许访问日历"); NSLog(@"用户没有点允许访问日历");
} }
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if(self.completion){ if(self.calendarCompletion){
self.completion(isGranted, isError); self.calendarCompletion(isGranted, isError);
} }
}); });
}]; }];
}else{ }else{
// 未授权 // 未授权
NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:@{NSLocalizedDescriptionKey : @"未授权"}]; NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:@{NSLocalizedDescriptionKey : @"未授权"}];
if (self.completion) { if (self.calendarCompletion) {
self.completion(NO, error); self.calendarCompletion(NO, error);
} }
} }
} }
...@@ -404,7 +406,10 @@ ...@@ -404,7 +406,10 @@
- (void)checkCompletedRemindersStartDate:(NSDate *)startDate addEndDate:(NSDate *)endDate fetchCompleted: (completed)completed { - (void)checkCompletedRemindersStartDate:(NSDate *)startDate addEndDate:(NSDate *)endDate fetchCompleted: (completed)completed {
self.completed = completed; self.completed = completed;
// 查询到所有的日历 // 查询到所有的日历
NSArray *tempA = [self.eventStore calendarsForEntityType: EKEntityTypeReminder];
EKEventStore * store = [[EKEventStore alloc] init];
NSArray *tempA = [store calendarsForEntityType: EKEntityTypeReminder];
NSMutableArray *only3D = [NSMutableArray array]; NSMutableArray *only3D = [NSMutableArray array];
for (int i = 0 ; i < tempA.count; i ++) { for (int i = 0 ; i < tempA.count; i ++) {
...@@ -416,7 +421,7 @@ ...@@ -416,7 +421,7 @@
[only3D addObject: temCalendar]; [only3D addObject: temCalendar];
} }
} }
self.eventStore = store;
NSPredicate *predicate = [self.eventStore predicateForCompletedRemindersWithCompletionDateStarting:startDate ending:endDate calendars:only3D]; NSPredicate *predicate = [self.eventStore predicateForCompletedRemindersWithCompletionDateStarting:startDate ending:endDate calendars:only3D];
// 获取到范围内的所有事件 // 获取到范围内的所有事件
......
...@@ -48,8 +48,10 @@ ...@@ -48,8 +48,10 @@
if (granted) { if (granted) {
NSArray *events = [[WMEventCalendarTool sharedCalendar] checkToStartDate:[NSDate dateWithTimeIntervalSince1970:1514375207] addEndDate: [NSDate date] addModifytitle:nil addCalendarIdentifier: nil]; NSArray *events = [[WMEventCalendarTool sharedCalendar] checkToStartDate:[NSDate dateWithTimeIntervalSince1970:1514375207] addEndDate: [NSDate date] addModifytitle:nil addCalendarIdentifier: nil];
self.events = events.mutableCopy; self.events = events.mutableCopy;
[self.tableView reloadData]; dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
[self.tableView layoutIfNeeded];
});
// for (int i = 0; i < events.count; i++) { // for (int i = 0; i < events.count; i++) {
// EKEvent *event = events[i]; // EKEvent *event = events[i];
// NSLog(@"%@ - %@",event.title,event.eventIdentifier); // NSLog(@"%@ - %@",event.title,event.eventIdentifier);
...@@ -65,9 +67,10 @@ ...@@ -65,9 +67,10 @@
[[WMEventCalendarTool sharedCalendar] checkCalendarReminderCanUsedCompletion:^(BOOL granted, NSError *error) { [[WMEventCalendarTool sharedCalendar] checkCalendarReminderCanUsedCompletion:^(BOOL granted, NSError *error) {
if (granted) { if (granted) {
[[WMEventCalendarTool sharedCalendar] checkCompletedRemindersStartDate:[NSDate dateWithTimeIntervalSince1970:1514375207] addEndDate:[NSDate date] fetchCompleted:^(NSArray<EKReminder *> *reminders) { [[WMEventCalendarTool sharedCalendar] checkCompletedRemindersStartDate:[NSDate dateWithTimeIntervalSince1970:1514375207] addEndDate:[NSDate date] fetchCompleted:^(NSArray<EKReminder *> *reminders) {
self.reminders = reminders.mutableCopy;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
self.reminders = reminders.mutableCopy;
[self.tableView reloadData]; [self.tableView reloadData];
[self.tableView layoutIfNeeded];
// // EKReminder *event = reminders[i]; // // EKReminder *event = reminders[i];
// for (EKReminder *reminder in reminders) { // for (EKReminder *reminder in reminders) {
// NSLog(@"提醒事项 - %@ ",reminder.title); // NSLog(@"提醒事项 - %@ ",reminder.title);
......
...@@ -60,19 +60,19 @@ ...@@ -60,19 +60,19 @@
#define ICLocalized(name) [NSString stringWithFormat:@"%@",NSLocalizedString(name, nil)] #define ICLocalized(name) [NSString stringWithFormat:@"%@",NSLocalizedString(name, nil)]
// 正常打印(包括方法名和代码所在的行数) // 正常打印(包括方法名和代码所在的行数)
#ifdef DEBUG //#ifdef DEBUG
//
#define ServerReport @"http://reporttest.zhangxinhulian.com" //#define ServerReport @"http://reporttest.zhangxinhulian.com"
#define ServerHost @"https://feedapitest.zhangxinhulian.com" // 服务端接口地址 //#define ServerHost @"https://feedapitest.zhangxinhulian.com" // 服务端接口地址
//
#define NSLog(format, ...) printf("\n[%s] %s [%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]); //#define NSLog(format, ...) printf("\n[%s] %s [%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else //#else
#define ServerReport @"http://report.zhangxinhulian.com" #define ServerReport @"http://report.zhangxinhulian.com"
#define ServerHost @"https://feedapi.zhangxinhulian.com" #define ServerHost @"https://feedapi.zhangxinhulian.com"
#define NSLog(format, ...) nil //#define NSLog(format, ...) nil
#endif //#endif
typedef enum: NSUInteger { typedef enum: NSUInteger {
SimilayNormalPhoto = 0, SimilayNormalPhoto = 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment