English 中文(简体)
CAL yer roll 气
原标题:CALayer scroll view slowdown with many items

Hey, I m, with CALayers in a levels support NSScrollView. 我 view切地认为,我带着一夫一妻的外科医生, next倒了次。 现在,所有我都在做的是,在他们周围划定边界,以便我能够看到这些边界。 各级别无选择。

业绩看来是罚款,直到2009年完成。 从滚动角度看,我约有1500人。 当我把1 500人列入名单时,我的业绩是巨大的,直到我接近项目1 000。 之后, app子开始hang。 这不是一种渐进的放慢,如果它刚刚达到它的能力,那么我会期望这种减速。 如同 app一样,它击中了一条砖墙。

当我把CGContextFillRect称作各个层次的精选方法时,减速在项目300左右。 我假定这一点与可能填写的录像卡记忆或做些什么? 我是否需要做一些事情,以便在我的滚动观点中排除了药房的资源?

我已注意到,如果我对我的层次不作定论,我就可以在不放慢的情况下结束1,500件物品。 然而,这不是一个解决办法,因为我有某种习俗,我必须在这个层面开展工作。 我不敢肯定,如果这个问题得到解决,或者仅仅让问题在层层中出现更多的项目。 理想的情况是,我希望在滚动观点(当然是出于某种原因)中把数千个项目列入议程。 现实地说,这些空闲物品中有多少件,我应指望能够以这种方式展示?

#import "ShelfView.h"
#import <Quartz/Quartz.h>

@implementation ShelfView

- (void) awakeFromNib
{
    CALayer *rootLayer = [CALayer layer];
    rootLayer.layoutManager = self;
    rootLayer.geometryFlipped = YES;

    [self setLayer:rootLayer];
    [self setWantsLayer:YES];

    int numItemsOnShelf = 1500;

    for(NSUInteger i = 0; i < numItemsOnShelf; i++) {
        CALayer* shelfItem = [CALayer layer];
        [shelfItem setBorderColor:CGColorCreateGenericRGB(1.0, 0.0, 0.0, 1.0)];
        [shelfItem setBorderWidth:1];
        [shelfItem setNeedsDisplay];
        [rootLayer addSublayer:shelfItem];
    }

    [rootLayer setNeedsLayout];
}

- (void)layoutSublayersOfLayer:(CALayer *)layer
{
    float y = 10;

    int totalItems = (int)[[layer sublayers] count];

    for(int i = 0; i < totalItems; i++)
    {
        CALayer* item = [[layer sublayers] objectAtIndex:i];

        CGRect frame = [item frame];            
        frame.origin.x = self.frame.size.width / 2 - 200;
        frame.origin.y = y;
        frame.size.width = 400;
        frame.size.height = 400;

        [CATransaction begin];
        [CATransaction setAnimationDuration:0.0];

        [item setFrame:CGRectIntegral(frame)];

        [CATransaction commit];
        y += 410;
    }

    NSRect thisFrame = [self frame];
    thisFrame.size.height = y;

    if(thisFrame.size.height < self.superview.frame.size.height) 
        thisFrame.size.height = self.superview.frame.size.height;

    [self setFrame:thisFrame];
}

- (BOOL) isFlipped
{
    return YES;
}

@end
最佳回答

我发现,这是因为我用海关图画填充每个层,它们似乎都是单独图像,尽管它们分享了许多共同数据,但我转而只是制造了十几个外科医生,填充了他们的“遗产”财产,并把它们作为主要层子添加。 这似乎使MUCH 齐ppier。

问题回答

暂无回答




相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签