1

ねえ、アプリの構築について助けが必要です。私はアートアプリを構築していますが、このアプリは干渉で動作しています。それが、このアプリで多くの線を引く必要がある理由です。相互参照には、より多くの行が適しています。問題は、速度またはパフォーマンスが遅すぎるため、iPad が多すぎる行を処理できないことだと思います。iPad でパフォーマンスを向上させるためにコードを高速化する方法がわかりません。OpenGLか何か他のものを使うべきですか...

私に何ができる?

これがDraw.mです

#import "Draw.h"

@implementation Draw


- (IBAction) sliderValueChanged:(UISlider *)sender {
    label.text = [NSString stringWithFormat:@"%f", slider.value];
    //NSLog(@"slider value = %f", sender.value);
    [self setNeedsDisplay];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

    }
    return self;
}




- (void)drawRect:(CGRect)rect
{

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    //NSLog(@"slider value = %f", self.bounds.size.width);

    CGMutablePathRef cgpath = CGPathCreateMutable();
    CGPathMoveToPoint(cgpath, NULL, 0, 500);


    CGMutablePathRef cgpath2 = CGPathCreateMutable();
    CGPathMoveToPoint(cgpath2, NULL, 0, 500);

    UIBezierPath *uipath = [[UIBezierPath alloc] init];
    [uipath moveToPoint:CGPointMake(0, 0)];

    int step = 5;
    int iterations = self.bounds.size.width/step;

    for (int i = 0; i < iterations+1; i++){
    //CGPathAddCurveToPoint(cgpath, NULL, 1+i, 0, 1+i, 0, 1+i ,0);

        CGPathAddLineToPoint ( cgpath,  NULL, 0, 0 );
        CGPathAddLineToPoint ( cgpath,  NULL, 0, 768 );
        CGPathAddLineToPoint ( cgpath,  NULL, step*i-slider.value*2, 768 );
        CGPathAddLineToPoint ( cgpath,  NULL, step*i, 0 );
        CGPathAddLineToPoint ( cgpath,  NULL, (step*i)+step, 0 );

    [[UIColor blackColor] setStroke];
    CGContextAddPath(ctx, cgpath);

    [self strokeUIBezierPath:uipath];

    CGPathRelease(cgpath);
}

- (void)strokeContext:(CGContextRef)context
{
    CGContextStrokePath(context);
}

- (void)strokeUIBezierPath:(UIBezierPath*)path
{
    [path stroke];
}

@end

画像 http://img17.imageshack.us/img17/375/53178410200339197475308.jpg

4

2 に答える 2

0

画面いっぱいにパターンを使用すると、パフォーマンスが向上するはずです。Quartz Programming Guide には、サンプル コードを含むセクション全体があります。

あなたの場合、非常に小さなパターン セル (高さ = 1) を作成し、左端に 1 つの黒いピクセルと、次の行までの距離と同じ数の白いピクセルが続きます。

于 2013-04-11T06:54:48.647 に答える