关于CALayer导致的crash问题
push到一个页面进行绘图时,设置如下:
CALayer * layer = [CALayer layer];
layer.frame = CGRectMake(, , , );
layer.delegate = self;
[layer setNeedsDisplay];
[self.view.layer addSublayer:layer];
-(void) drawLayer: (CALayer*) layer inContext: (CGContextRef) context;
设置delegate后,点击返回按钮时会奔溃。没有push直接绘制的时候就没有问题。
设置其delegate为uiview类型实例。会导致程序crash。
关于这一点,苹果官方在文档中已有说明。解决办法:
he lightest-wight solution would be to create a small helper class in the the file as the UIView that's using the CALayer: In MyView.h @interface MyLayerDelegate : NSObject
. . .
@end
In MyView.m @implementation MyLayerDelegate
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx
{
. . .
}
@end
Just place those at the top of your file, immediately below the #import directives. That way it feels more like using a "private class" to handle the drawing (although it isn't -- the delegate class can be instantiated by any code that imports the header).
没怎么看懂:
直接继承CALayer或者CAShapeLayer重写:
- (void)drawInContext:(CGContextRef)ctx
就可以
关于CALayer导致的crash问题的更多相关文章
- 打开Voice Over时,CATextLayer的string对象兼容NSString和NSAttributedString导致的Crash(二解决思路3)
续前一篇:打开Voice Over时,CATextLayer的string对象兼容NSString和NSAttributedString导致的Crash(二解决思路2)ok,到这里已经能够锁定范围了, ...
- 案例:Standby RAC遭遇ORA-1157,1111,1110导致实例crash处理
案例:Standby RAC遭遇ORA-1157,1111,1110导致实例crash处理 环境:RHEL 6.5 + Oracle RAC 11.2.0.4 + Dataguard 今天在实验环境的 ...
- 解决iOS7中UITableView在使用autolayout时layoutSubviews方法导致的crash
近期公司项目上线后,出现了大量的crash,发生在iOS7系统上,和UITableView相关: Auto Layout still required after executing -layoutS ...
- 一些Windows API导致的Crash以及使用问题总结
RegQueryValueEx gethostbyname/getaddrinfo _localtime64 FindFirstFile/FindNextFile VerQueryValue Crea ...
- 打开Voice Over时,CATextLayer的string对象兼容NSString和NSAttributedString导致的Crash(一现象)
一.现象:iPhone真机打开Voice Over的情况下,iPhone QQ空间工程,Xcode 真机编译启动必Crash,main函数里面 NSSetUncaughtExceptionHandle ...
- Latch导致MySQL Crash
作者:沃趣科技数据库专家 董红禹 问题概述 最近我们遇到一个MySQL的问题,分析后很有代表意义,特地写出来供大家参考.出现问题是,数据库先是被置为只读,然后过了一段时间,MySQL直接Crash掉了 ...
- 一些Windows API导致的Crash以及使用问题总结(API的AV失败,可以用try catch捕捉后处理)
RegQueryValueEx gethostbyname/getaddrinfo _localtime64 FindFirstFile/FindNextFile VerQueryValue Crea ...
- 捉虫日记 | MySQL 5.7.20 try_acquire_lock_impl 异常导致mysql crash
背景 近期线上MySQL 5.7.20集群不定期(多则三周,短则一两天)出现主库mysql crash.触发主从切换问题,堆栈信息如下: 从堆栈信息可以明显看出,在调用 try_acquire_loc ...
- systemd之导致内核 crash
本文主要讲解linux kernel panic系列其中一种情况: Attempted to kill init! exitcode=0x0000000b 背景:linux kernel 的panic ...
随机推荐
- Python3.4+Django1.9+Bootstrap3
实现和原理 Python集成Django开发框架后,可以通过在cmd命令提示符下建立工程,工程名为learn_models 1 django-admin.py startproject learn_m ...
- Java中System类的相关应用
1.Runtime: public class RuntimeDemo { public static void main(String[] args) { Runtime runtime=Runti ...
- CNN:人工智能之神经网络算法进阶优化,六种不同优化算法实现手写数字识别逐步提高,应用案例自动驾驶之捕捉并识别周围车牌号—Jason niu
import mnist_loader from network3 import Network from network3 import ConvPoolLayer, FullyConnectedL ...
- react+typescript报错集锦<持续更新>
typescript报错集锦 错误:Import sources within a group must be alphabetized.tslint(ordered-imports) 原因:impo ...
- Xamarin Essentials教程使用指南针Compass
Xamarin Essentials教程使用指南针Compass 指南针是一种确定地理方向的工具.在手机应用程序中,指南针通过手机的磁力计确定磁北极,提供手机方向信息.在Xamarin中,开发者可 ...
- Xamarin Essentials教程语音播报TextToSpeech
Xamarin Essentials教程语音播报TextToSpeech 语音播报是一种将文本信息转化为音频信息的技术.使用该技术,开发者可以让用户不用盯着屏幕,就可以获取到信息.例如,支付宝为商 ...
- 【PYTHON】 Missing parentheses in call to 'print'
Microsoft Windows [版本 10.0.15063] (c) 2017 Microsoft Corporation.保留所有权利. C:\Users\Jam>python Pyth ...
- php 操作json的各种格式
php中操作json的函数 加密:json_encode() ,也就是把数据转成json格式 * 数组转换成json格式时,索引数组得出的结果是不带映射关系,所以都是[]:关联数组是映射,所以最外围是 ...
- 简单的C程序
1.最简单的C程序 #include<stdio.h> //预编译处理指令 int main() // 定义主函数 { printf("hello world"); } ...
- 超详细Gitlab Runner环境配置中文教程
配置GitlabRunner环境 GitLab Runner 是一个开源项目, 它用来运行你定制的任务(jobs)并把结果返回给 GitLab. GitLab Runner 配合GitLab CI(G ...