由于EKEvent加载大量数据,导致UI冻结

问题描述

根据我的经验,我正在获取提醒,该提醒可以正常运行,但日历不能很好地运行。当我打开提醒并开始提取时,我注意到加载栏工作正常。例如,负载为0%,5%,20%... 100%。但是,当我打开日历时,卡在0%处,但打印结果显示0、1、2,... 100,直到完成获取日历为止,然后立即将栏加载更改为100%。 (对不起,我的英语太烂了,我正在使用ASL,希望您理解我的意思。)

可以正常工作的提醒代码,UI不会冻结。我对此没有问题:

ReminderDataVar.ReminderStore.fetchReminders(matching: ReminderDataVar.ReminderType,completion: {(listofReminder: [EKReminder]!) -> Void in
   for getReminderDetail in listofReminder {
      //Code goes here
   }
})

日历代码,这将导致UI在加载日历时冻结。另外,我发现与提醒不同:

let EventPre = CalendarDataVar.CalendarStore.predicateForEvents(withStart: getCalTypeS,end: getCalTypeE,calendars: [searchCategory])
let FetchTodayEvents = CalendarDataVar.CalendarStore.events(matching: EventPre)
for fetDetail in FetchTodayEvents {
   //Code goes here
}

我尝试了dispatchQueue.main.async,在堆栈溢出问题中到处都没有发现这些问题。 UI将冻结,直到完成日历的获取,但打印结果没有冻结。我错过了什么?

同样,所有代码看起来都不错,日历工作得很好,我唯一的问题是加载时,UI会冻结。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)