惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
罗磊的独立博客
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
Jina AI
Jina AI
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
C
Check Point Blog
GbyAI
GbyAI

博客园 - 张永存(Jerry)

POD 创建 Xcode 项目组 ReactiveCocoa RACObserve subscribeNext 时,只有值不一样时才响应 ReactiveCocoa 监听Enabled和添加Command出错的处理方法 Masonry + UIView Animations 注意事项 ios中tabbar得title和navigationbar的title如何修改 tableview 分组显示返回footerviewt和headerView的高度不能为0的问题 UITableViewCell的选中时的颜色设置 ios 枚举 位移操作 设置UIButton 字体 颜色 ios NSString format 保留小数点 float double 屏幕自动旋转和调节大小 IOS影响Animiation动画的事件 类似9patch效果的iOS图片拉伸 CocoaPods安装 Mac OS X上安装 Ruby运行环境 XMPP 连续注册出现用户限制:500错误 处理方式 ejabberd 搭配的XMPP服务器注册失败 403 处理 在framework中打包xib 【转】 XMPP ejabberd服务 Mac 安装
addObserver forKeyPath options 注意事项
张永存(Jerry) · 2015-11-27 · via 博客园 - 张永存(Jerry)

[self.layer addObserver:self forKeyPath:@"cornerRadius" options:NSKeyValueObservingOptionNew context:nil];

添加一个监听

在运行过程中可能出现错误

EXC_BAD_ACCESS

这是因为没有在dealloc中removeObserver的问题

但是有时不确定一个监听有没有添加时,

在dealloc进行removeObserver时又会报

because it is not registered as an observer.

这是因为穿点监听没有添加

但IOS不提供addObserver是否添加的判断功能

所以这里最好写为

@try

{

[self.layer removeObserver:self forKeyPath:@"cornerRadius"];

}

@catch(id exception){}

Blog都是随笔,只当做笔记,不会有详细介绍,测试请慎重。。。

posted @ 2015-11-27 12:03  张永存(Jerry)  阅读(1963)  评论(0)    收藏  举报