xcode - iOS执行drawLayer:incontext,pop操作后闪退
本文介绍了xcode - iOS执行drawLayer:incontext,pop操作后闪退的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
看CA教程,执行完drawLayer后闪退,demo如下
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
//线宽
CGContextSetLineWidth(ctx, 10.0f);
//线颜色
CGContextSetStrokeColorWithColor(ctx, [UIColor greenColor].CGColor);
//画椭圆
CGContextStrokeEllipseInRect(ctx, layer.bounds);
}
是需要释放指针咩?
解决方案
问题出在layer.delegate
添加这个
-
(void)dealloc {
yourLayer.delegate = nil;
}
另外关于layer delegate苹果的说明
http://stackoverflow.com/questions/2015353/using-calayer-delegate
这篇关于xcode - iOS执行drawLayer:incontext,pop操作后闪退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文