关于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 ...
随机推荐
- linuxDNS配置
DNS配置 vim /etc/resolv.conf nameserver 114.114.114.114
- Sunscreen POJ - 3614(贪心)
To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with s ...
- POJ 1988 Cube Stacking 【带权并查集】
<题目链接> 题目大意: 有几个stack,初始里面有一个cube.支持两种操作: 1.move x y: 将x所在的stack移动到y所在stack的顶部. 2.count x:数在x所 ...
- linux学习笔记 其他常用命令
cd + 回车 = cd ~ 进入当前用户主目录 查看指定进程信息 *ps -ef |grep 进程名 *ps -查看属于自己的进程 *ps -aux 查看所有的用户的执行进程 换成 ps - ...
- C#如何使用REST接口读写数据
原网站:http://www.codeproject.com/Tips/497123/How-to-make-REST-requests-with-Csharp 一个类,我们拷贝下来直接调用就行: 以 ...
- 37_Reverse3_digit_Integer
描述 反转一个只有3位数的整数. 你可以假设输入一定是一个只有三位数的整数,这个整数大于等于100,小于1000. [ ] 您在真实的面试中是否遇到过这个题? 样例 123 反转之后是 321. 90 ...
- ICPC Asia Regional 2015 Japan.Routing a Marathon Race(DFS)
vjudge \(Description\) 给定一张\(n\)个点\(m\)条边的无向图,每个点有一个权值.求一条从\(1\)到\(n\)的路径,使得代价最小,输出最小代价. 一条路径的代价定义为, ...
- BZOJ.3676.[APIO2014]回文串(回文树)
BZOJ 洛谷 很久之前写(抄)过一个Hash+Manacher的做法,当时十分懵逼=-= 然而是道回文树模板题. 回文树教程可以看这里(真的挺妙的). 顺便再放上MilkyWay的笔记~ //351 ...
- STM32——C语言课堂原代码
指针 /* ============================================================================ Name : Hello.c Au ...
- Coins [POJ1742] [DP]
Description 给出硬币面额及每种硬币的个数,求从1到m能凑出面额的个数. Input 多组数据,每组数据前两个数字为n,m.n表示硬币种类数,m为最大面额,之后前n个数为每种硬币的面额, ...