2

我有一个网格视图,我想在这个网格视图的每个单元格内绘制矩形,

这里的矩形代表一个事件或提醒,所以当我从本地日历中获取提醒和事件时,我会过滤它们以分别获取每天的事件,这样我就可以在网格视图中的适当单元格中绘制它们,但是这种方法的性能很差.

那么如何才能在网格视图中以优异的性能绘制这些事件呢?如何避免每月每天过滤事件产生的延迟?

4

2 回答 2

3

I am assuming what you are doing now is that you are getting the entire contents of the grid view rectangles simultaneously.

What you can do is to load the grid view rectangles with the events/reminders in a background thread so that you do not jam up the UI while your data is loading. Try using Apple's Grand Central Dispatch to do your loading in another thread.

Something along the lines of

dispatch_async(DISPATCH_QUEUE_PRIORITY_DEFAULT, ^{
        // Your code to get data
    });
于 2012-07-04T10:00:31.400 回答
0

使用 NSOperationQueue 做一个后台进程

于 2012-07-25T09:06:02.030 回答