Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 重画时出现CGPath性能问题_Ios_Xcode_Cgpath - Fatal编程技术网

Ios 重画时出现CGPath性能问题

Ios 重画时出现CGPath性能问题,ios,xcode,cgpath,Ios,Xcode,Cgpath,我目前正在开发的应用程序的性能有一些奇怪的问题。一个视图使用自建信息图,类似于polarchart。每8秒重新绘制一次。 前五次重画时一切正常,但之后滚动视图(显示信息图的视图的超级视图)开始严重结巴。下面是生成图形的代码的基本部分 [_chartLayer从SuperLayer移除]; _chartLayer=[CALayer层] CAShapeLayer *segment = [mySegmentProducer produceSegmentWith:startAngle and: en

我目前正在开发的应用程序的性能有一些奇怪的问题。一个视图使用自建信息图,类似于polarchart。每8秒重新绘制一次。 前五次重画时一切正常,但之后滚动视图(显示信息图的视图的超级视图)开始严重结巴。下面是生成图形的代码的基本部分

[_chartLayer从SuperLayer移除]; _chartLayer=[CALayer层]

  CAShapeLayer *segment = [mySegmentProducer produceSegmentWith:startAngle and: endAngle and: radius and: sliceAngle];
    [_chartLayer addSublayer:segment];
    [self.layer addSublayer:_chartLayer];
下面是函数produceSegmentWith:放置在另一个类中:

- (CAShapeLayer*) produceSegmentWith:(float)startAngle and:(float)endAngle and:(float) radius and: (float) sliceAngle  {

CAShapeLayer *segment = [CAShapeLayer layer];

CGPathRef pathTwo = [self addSegmentPath: radius fromStartAngle:startAngle toEndAngle:endAngle];

// hue = 224 / 360 initial value

segment.fillColor = [UIColor colorWithHue:self.hue/360 saturation:0.5 brightness:0.63 alpha:1.0].CGColor;
segment.lineWidth = 0.0;
segment.path = pathTwo;
self.hue-= 15;
return segment;
}


我是舒尔,我在这里做的有些不对劲。在其他帖子中,我看到总是使用函数CGPathRelease。但我不知道舒尔如何正确使用它。当我把它放在返回段上方的行中时,我总是会得到一个坏线程访问异常。谁能给我指引正确的方向

快速看一眼。。。您每次都在添加新的形状层。。。在添加新实例之前,请尝试删除上次添加的实例。您应该做的第一件事是运行仪器以查看发生了什么。我要提到的是,在CALayer实例之上有以下函数[_ChartLayerRemoveFromSuperLayer];和_chartLayer=[CALayer layer];从superlayer中删除时是否删除了_chartLayer?