当 NSSetUncaughtExceptionHandler 被调用时,我试图在屏幕上绘制一些简单的东西,但什么也没有发生。 有没有其他方法可以捕获异常并快速在屏幕上绘制内容?
NSSetUncaughtExceptionHandler(&exceptionHandler);
void exceptionHandler(NSException *exception)
{
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(10.0, 10.0)];
[path moveToPoint:CGPointMake(10.0, 10.0)];
[path addLineToPoint:CGPointMake(10.0, 450.0)];
[path addLineToPoint:CGPointMake(310.0, 450.0)];
[path addLineToPoint:CGPointMake(310.0, 10.0)];
[path addLineToPoint:CGPointMake(10.0, 10.0)];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [path CGPath];
shapeLayer.strokeColor = [[UIColor blueColor] CGColor];
shapeLayer.lineWidth = 3.0;
shapeLayer.fillColor = [[UIColor clearColor] CGColor];
[APP_DELEGATE_WINDOW.rootViewController.view.layer addSublayer:shapeLayer];
[APP_DELEGATE_WINDOW makeKeyAndVisible];
}
最佳答案
我不确定 NSSetUncaughtExceptionHandler
是否是在屏幕上绘制内容的好地方。
Sets the top-level error-handling function where you can perform last-minute logging before the program terminates.
大多数崩溃报告者都会仔细记录痕迹,并尽量不要“触摸”除此之外的任何东西。
如果你真的想画一些东西(什么?),你可能应该首先捕获一个特定的异常。只是没有任何未捕获的异常。
关于ios - 当点击 NSSetUncaughtExceptionHandler 时,使用 CoreGraphics 在屏幕上绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25125728/