代码:@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; /// 添加通知中心观察者 [[NSNotificationCenter defaultCenter] addObserver:s...
分类:
编程语言 时间:
2015-06-18 21:29:12
阅读次数:
132
注册通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(TongZhiJianTingFangFa:) name:@"TongZhi_Type" object:nil];
通知监听的方法
#pragma mark (通知处理)接收通知更改频道名称
- (void...
分类:
移动开发 时间:
2015-06-16 16:47:29
阅读次数:
121
与javascript中的事件机制不同,ios里的事件广播机制是同步的,默认情况下,广播一个通知,会阻塞后面的代码:
Objc代码
-(void) clicked
{
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center pos...
分类:
移动开发 时间:
2015-06-09 09:51:25
阅读次数:
168
处理文本输入框的输入事件,单击文本输入框后要弹出键盘。弹出键盘有两种实现方式:一种代理,一种通知。也就是对应的(观察者模式和代理模式)。1、通知 1.1、准备工作 每一个应用程序都有一个通知中心(NSNotificationCenter)实例,专门负责协助不同对象之间的消息通信。 任何...
分类:
移动开发 时间:
2015-06-08 16:40:22
阅读次数:
195
注册:[[NSNotificationCenter defaultCenter] postNotificationName:@"changeColor" object:self];接收处观察 : [[NSNotificationCenter defaultCenter] addObserver:se...
分类:
移动开发 时间:
2015-06-07 18:46:31
阅读次数:
139
转自:http://blog.csdn.net/liliangchw/article/details/8276803对象之间进行通信最基本的方式就是消息传递,在Cocoa中提供Notification Center机制来完成这一任务。其主要作用就是负责在任意两个对象之间进行通信。使用方法很简单,如下...
分类:
移动开发 时间:
2015-06-06 23:17:39
阅读次数:
217
通过向 NSNotificationCenter 注册观察者监听键盘事件,根据键盘状态,从而动态调整 UITextView的 edgeInsets #import?"ViewController.h"
@interface?ViewController?()
@property?(nonatomic,?strong)?U...
分类:
其他好文 时间:
2015-06-01 11:47:34
阅读次数:
198
在appdelegate里面添加观察者,并启动监测 // 使用通知中心监听kReachabilityChangedNotification通知 [[NSNotificationCenter defaultCenter] addObserver:self ...
分类:
其他好文 时间:
2015-05-29 17:48:52
阅读次数:
148
1、属性传值前向后传值。2、协议传值3、Block传值代替协议代理传值,主要时间点问题。4、单利传值数据共享。5、通知传值通知中心NSNotificationCenter提供了一种更加解耦的方式。最典型的应用就是任何对象对可以发送通知到中心,同时任何对象可以监听中心的通知。发送通知的代码如下:[[N...
分类:
移动开发 时间:
2015-05-29 13:34:19
阅读次数:
149
//注册键盘出现的通知
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
...
分类:
移动开发 时间:
2015-05-27 12:24:04
阅读次数:
220