ios 各种通知

//旋转屏幕通知

[[NSNotificationCenter defaultCenter] addObserver:self

selector:@selector(onDeviceOrientationChange)

name:UIDeviceOrientationDidChangeNotification

object:nil

];


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fullScreenBtnClick:) name:@"fullScreenBtnClickNotice" object:nil];

// 添加视频播放结束通知

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(moviePlayDidEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:_currentItem];

[[NSNotificationCenter defaultCenter] removeObserver:self];


// 单击的 Recognizer

UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap)];

singleTap.numberOfTapsRequired = 1; // 单击

[self addGestureRecognizer:singleTap];

// 双击的 Recognizer

UITapGestureRecognizer* doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap)];

doubleTap.numberOfTapsRequired = 2; // 双击

[self addGestureRecognizer:doubleTap];

//注册播放完成通知

//uitextflief通知

1,在initWithNibName中注册对应的通知:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldChanged:) name:UITextFieldTextDidChangeNotification object:_passwordTextField];

}

return self;

}

2,实现textFieldChanged函数

- (void)textFieldChanged:(id)sender

{

NSLog(@"current ContentOffset is %@",NSStringFromCGPoint(_contentView.contentOffset));

}

3,记得在dealloc中删除掉通知。

- (void)dealloc

{

[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];

}

你可能感兴趣的:(ios 各种通知)