关于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 ...
随机推荐
- Flume配置文件写法总结
一.agent 第一步是定义agent(代理)及agent下的sources.channels.sinks的简称,如下: a1.sources = r1 a1.sinks = k1 a1.channe ...
- poj 3368 Frequent values(经典)【RMQ】
<题目链接> 题目大意: 给你一个长度为n的序列,这个序列每个数都有一个值,接下来进行q次询问,问在指定区间内出现次数最多的数出现了几次. 解题分析: 因为该序列是非降序的,所以该序列中的 ...
- mybatis之级联关系(一对一、一对多)
0. 表结构 1. 准备工作 1.1 配置文件等信息,请参考 myBatis之入门示例 1.2 entity 1.2.1 TPersonInfo.java package com.blueStarW ...
- source命令用法详解
source命令用法 1 source FileName source命令作用 在当前bash环境下读取并执行FileName中的命令. *注:该命令通常用命令“.”来替代. 使用范例: 1 2 so ...
- 栈 VS 队列
linkStack.javalinkQueue.java程序强调栈和队列是概念上的实体,独立于它们的具体实现.用数组或者是用链表实现栈都是一样的.栈的重要性在于它的push()操作和pop()操作.以 ...
- KenBurns特效组件KenBurnsView
KenBurns特效组件KenBurnsView KenBurns特效是一种静态图片展现方式.通过镜头缩放和平移的方式来展现图片,让静态图片产生动态视觉的效果.KenBurns特效可以通过KenB ...
- vue-router那些事儿
vue-router适用于单页面应用. 一.vue-router的引用方法1.用script标签 <script src="https://unpkg.com/vue-router/d ...
- python基础一 ------如何获取多个字典相同的键
需求: 足球赛第一场进去统计 {"A":3,"B":2,"C":1}足球赛第二场进去统计 {"A":3," ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习1
#include <iostream>using namespace std;int main(){ int min,max; cout<<"Enter the mi ...
- linux查看服务安装目录
linux查看服务安装目录server dir 假如我们想查看 Redis 的安装目录 如果用命令 which redis 或者 whereis redis 都找不到安装目录, 可使用以下办法: ps ...