读书人

[转]不同控制器其间通信的一个好方法

发布时间: 2012-07-27 11:03:01 作者: rapoo

[转]不同控制器之间通信的一个好方法
首页在view1的控制器初始化init方法里加上观察者模式方法:

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadChat:)
name:@”reloadChat” object:nil];

-(void)reloadChat:(id)sender{}

在view2里的button添加用来触发view1的reloadChat方法:

[[NSNotificationCenter defaultCenter] postNotificationName:@”reloadChat” object:self];

—END—

原文: http://sue602.blog.163.com/blog/static/314953072010102423136387/

读书人网 >移动开发

热点推荐