これは私がこれまでに直面した非常に困難な課題です。指を動かすと線が引けます。線は、図面ビューに存在するイメージビューをバイパスするように作成されます。以下のコードを使用しています。
コード:-
-(void) paintLinesinContext:(CGContextRef)context{
for (Line *line in lines) {
NSMutableArray *arrayOfPoints=[line getPointsArray];
CGContextBeginPath(context);
int numberofPoints=[arrayOfPoints count] ;
CGPoint points[numberofPoints];
int index=0;
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]);
if (line==tmpline) {
float dashPhase=10;
float dashPattern[3]={5,5};
CGContextSetLineDash(context, dashPhase, dashPattern, 2);
CGContextSetStrokeColorWithColor(context, [[UIColor redColor] CGColor]);
}
for (NSValue *pointObject in arrayOfPoints) {
points[index]= [pointObject CGPointValue];
if (index==0) {
CGContextMoveToPoint(context, points[index].x,points[index].y);
}
else {
CGContextAddLineToPoint(context, points[index].x, points[index].y);
}
index++;
}
CGContextStrokePath(context);
float dashPhase=10;
float dashPattern[3]={1,0};
CGContextSetLineDash(context, dashPhase, dashPattern, 2);
}
}
私の問題は、メモリ不足のためにアプリがクラッシュすることです。計測器の割り当てを使用して調べたところ、CGPath がより多くのメモリを占有していることに気付きました。信じようと信じまいと。私のアプリは 48MB で実行されており、そのうち 90MB が CGPath である 96MB にジャンプします。理由がわかりません誰か助けてください。