自定义UIView怎么注册销毁NSNotification通知
2024-08-26 10:14:05
问题描述:在使用天猫tangram框架后。部分组件自定义后会用到通知,但是在iOS 8 系统中,会崩溃?
原因分析:当对象挂掉后,要对应移除注册的通知。 否则当你重复执行发送通知的时候,在iOS8 系统以下,就会崩溃(其他系统暂时没有发现)。我们需要
在接受通知的类里移除通知。但是对于自定义的UIView类,该怎么操作呢?
方案解决:
//移除通知方法'
- (void)willMoveToWindow:(UIWindow*)newWindow {
if(newWindow == nil) {
// Will be removed from window, similar to -viewDidUnload.'
// Unsubscribe from any notifications here.'
[[NSNotificationCenterdefaultCenter] removeObserver:self];
}
}
//添加通知方法'
- (void)didMoveToWindow {
if(self.window) {
// Added to a window, similar to -viewDidLoad.'
// Subscribe to notifications here.'
[PublicFunctionaddObserver:selfnotificationName:@"refreshTheOpPersonalActivity"selector:@selector(clearTheArryData) object:nil];
}
}
最新文章
- java 基础导航
- 分享一个UI与业务逻辑分层的框架(三)
- 报表软件JS开发引用HTML DOM的windows对象
- C#在数据层过滤属性中的主键
- IP转换hash以及返回
- 详解 Spotlight on MySQL监控MySQL服务器
- AIX主机信任关系配置
- 给文件加ip访问限制
- zju 1091
- expdp与impdp
- 【React Native 实战】微信登录
- 浅谈Java泛型中的extends和super关键字(转)
- HDU 1131 Count the Trees
- 标准I/O 缓存
- linux下查找某个文件或目录
- java第三次上机
- Nginx 优先选择连接最少的上游服务器
- TXLSReadWriteII5 单元格读写
- 转:pycharm community debug django projects
- linux shell脚本中 mode=${1:-sart} filename=${fileuser:-";filename";}
热门文章
- ZooKeeper(一)基本介绍
- 强连通分量算法·$tarjan$初探
- (转)Jmeter http请求之content-type
- 1347: Last Digit (周期函数)
- [图解tensorflow源码] Session::Run()流程图 (单机版)
- 系统重装后恢复Oracle数据库
- ASP.NET中关于XML的AJAX的读取与删除
- windowbuilder
- 20155332 补交课后测试——ch11网络编程
- 5285: [Hnoi2018]寻宝游戏