ios 监听(NSNotification)的使用(在项目中已使用) .
2013-07-12 16:58
459 查看
我这是ipad开发,在首次进入系统后,点击左边视图的添加按钮,然后presentModalViewController添加登陆用户的视图。
在视图保存数据是然后请求监听触发事件,在leftViewController页面进行请求的接受
1.注册监听器
-(void)goChange:(NSNotification *)notification
{
//拿到通知内容。
NSDictionary *dic = [notification
userInfo];
ZYRootViewController *rootView=[[ZYRootViewController
alloc] init];
rootView.userListArray=[dic
objectForKey:@"myTable"];
[rootView.myTableView
reloadData];
}
2.在loadview方法注册监听者
//注册监听者。
[[NSNotificationCenter
defaultCenter]addObserver:self
selector:@selector(goChange:)
name:@"myTableView"
object:nil];
//收到通知后,执行方法:goChange:,object:nil表示所有的用户
3.点击保存按钮的请求触发事件(执行监听者选择器的方法)
User *user=[[User
alloc] init];
ZYRootViewController *rootView=[[ZYRootViewController
alloc] init];
rootView.userListArray=[user
getUser];
[rootView.myTableView
reloadData];
[user release];
[rootView release];
NSDictionary *dic = [NSDictionary
dictionaryWithObject:rootView.userListArray
forKey:@"myTable"];
[[NSNotificationCenter
defaultCenter]postNotificationName:@"myTableView"
object:self
userInfo:dic];
在视图保存数据是然后请求监听触发事件,在leftViewController页面进行请求的接受
1.注册监听器
-(void)goChange:(NSNotification *)notification
{
//拿到通知内容。
NSDictionary *dic = [notification
userInfo];
ZYRootViewController *rootView=[[ZYRootViewController
alloc] init];
rootView.userListArray=[dic
objectForKey:@"myTable"];
[rootView.myTableView
reloadData];
}
2.在loadview方法注册监听者
//注册监听者。
[[NSNotificationCenter
defaultCenter]addObserver:self
selector:@selector(goChange:)
name:@"myTableView"
object:nil];
//收到通知后,执行方法:goChange:,object:nil表示所有的用户
3.点击保存按钮的请求触发事件(执行监听者选择器的方法)
User *user=[[User
alloc] init];
ZYRootViewController *rootView=[[ZYRootViewController
alloc] init];
rootView.userListArray=[user
getUser];
[rootView.myTableView
reloadData];
[user release];
[rootView release];
NSDictionary *dic = [NSDictionary
dictionaryWithObject:rootView.userListArray
forKey:@"myTable"];
[[NSNotificationCenter
defaultCenter]postNotificationName:@"myTableView"
object:self
userInfo:dic];
相关文章推荐
- iOS 项目中的NSNotification简单使用
- IOS NSNotificationCenter(通知 的使用)监听文本框的文字改变
- iOS 监听(NSNotification)的优缺点和项目实践应用
- iOS项目开发实战——使用CALayer实现图片的淡入淡出效果
- iOS-SQLite在项目中实际使用(Objective-C)
- 查找iOS项目中是否使用了UDID
- iOS项目中全局变量的定义与使用
- iOS NSNotification 通知的使用
- iOS中使用脚本打包项目
- 使用OClint进行iOS项目的静态代码扫描
- iOS 静态类库项目的建立与使用
- 【iOS系列】- 通知NSNotification的使用
- PhoneGap教程:使用PhoneGap命令行工具快速创建IOS PhoneGap项目
- 检查iOS项目中是否使用了IDFA
- iOS使用Workspace来管理多项目
- git 常用命令 使用及iOS开发使用git管理项目步骤
- iOS项目开发实战——使用同步请求获取网页源码
- 使用github管理iOS分布式项目开发
- iOS UIScrollView的代理的使用及缩放时代理监听的几个方法