在绘制图形时仅在设备中使用 CGMutablePathRef 时导致应用程序崩溃

Crashing the App when using CGMutablePathRef in only device while drawing Graph

提问人:Sudheer Kumar Palchuri 提问时间:10/12/2013 最后编辑:Sudheer Kumar Palchuri 更新时间:10/12/2013 访问量:145

问:

    CGMutablePathRef smoothedCGPath = CreateSmoothedBezierPathFromPath(self.CGPath, tension);

当我调用该方法时

CreateSmoothedBezierPathFromPath(self.CGPath, tension);

CGMutablePathRef CreateSmoothedBezierPathFromPath( CGPathRef path, CGFloat tention)
{
    //convert path to 2 arrays of CGFloats
    struct dataPointer my_dataPointer; //this struct will hold the 2 indexes of the CGpath
    my_dataPointer.numberOfPoints = 0;
    my_dataPointer.isClosed = NO;
    CGPathApply(path, &my_dataPointer, savePathToArraysApplierFunc);

//the arrays where the control points will be stored
CGFloat controlPoints_x[2*_max_points];
CGFloat controlPoints_y[2*_max_points];

calculateBezierControlPoints(  controlPoints_x, controlPoints_y, my_dataPointer.indexx , my_dataPointer.indexy, my_dataPointer.isClosed, my_dataPointer.numberOfPoints, tention);

//the final CGpath constisting of original points and computed control points
CGMutablePathRef bezierPath = CGPathCreateMutable();

for (int i = 0; i<my_dataPointer.numberOfPoints + (int) my_dataPointer.isClosed; i++) 
{
    if(i==0)
        CGPathMoveToPoint(bezierPath, nil, my_dataPointer.indexx[0], my_dataPointer.indexy[0]);
    else if (i==my_dataPointer.numberOfPoints) //this happens when the path is closed
        CGPathAddCurveToPoint(bezierPath, nil, controlPoints_x[i*2-2], controlPoints_y[i*2-2], controlPoints_x[i*2-1], controlPoints_y[i*2-1],my_dataPointer.indexx[0], my_dataPointer.indexy[0]);
    else
        CGPathAddCurveToPoint(bezierPath, nil, controlPoints_x[i*2-2], controlPoints_y[i*2-2], controlPoints_x[i*2-1], controlPoints_y[i*2-1],my_dataPointer.indexx[i], my_dataPointer.indexy[i]);
}
if(my_dataPointer.isClosed)
    CGPathCloseSubpath(bezierPath);

return bezierPath;

}

在上面的方法中,返回 bezierPath 使设备中的 App 崩溃,它崩溃了,没有崩溃原因。它在模拟器中工作正常。

iPhone iOS Objective-C iOS4 核心图形

评论

0赞 user1118321 10/13/2013
“它崩溃了,没有崩溃原因”是什么意思?崩溃日志是什么样的?你怎么知道它在上述函数中崩溃了?
0赞 Sudheer Kumar Palchuri 10/13/2013
当我使用设备进行调试时,应用程序在到达最后一行时崩溃 return bezierPath;它不会在控制台中打印崩溃原因。
0赞 user1118321 10/14/2013
调试器显示什么?通常,它会停在有问题的行上,并在栏中显示突出显示该行的文本,该行显示“EXEC_BAD_ACCESS”或其他消息。另外,您是否有“C++ 异常中断”或“Objective-C 异常中断”?
0赞 Sudheer Kumar Palchuri 10/15/2013
我签入了设备日志,它是 异常类型:EXC_CRASH (SIGABRT) 异常代码:0x0000000000000000,0x0000000000000000 崩溃线程:0
0赞 user1118321 10/16/2013
通常,中止是由调用 或 引起的。有时,这种情况可能发生在库调用中,但通常不会发生。你能发布线程 0 的堆栈跟踪吗?assert()exit()

答: 暂无答案