通知

来源:互联网 发布:师范 校园网络电视 编辑:程序博客网 时间:2024/05/17 09:24

1.通知(能委托不通知)
1.1作用:完成对象之间的消息传递
1.2核心理念
1.通知的发送方式不知道接收方是谁,只需要将通知发给通知中心即可;
2.通知的接收方不知道发送方是谁,只需要提前向通知中心订阅某一个通知即可;
3.一旦通知的发送方真的发出了通知,则有通知中心负责将这个通知推送给负责给所有订阅了该通知的对象;
1.3通知和委托的对比:
1.代理只是两个对象之间。私密的消息的传递;
2.通知可以是一个对象对多个对象的消息传递,但彼此并不知道对方的存在;
1.4核心对象
1.通知中心:NSNotificationCenter(单例,系统自动创建好的)
2.通知NSNotification
1.5系统提供的通知:键盘通知
1.系统会在键盘弹起和收回时自动发出通知
键盘通知的名字:
键盘弹起:
UIKeyBoardWillShowNotification
UIKeyBoardDidShowNotification

  1. UIKeyboardAnimationCurveUserInfoKey = 7;
    UIKeyboardAnimationDurationUserInfoKey = “0.25”;
    UIKeyboardBoundsUserInfoKey = “NSRect: {{0, 0}, {414, 271}}”;
    UIKeyboardCenterBeginUserInfoKey = “NSPoint: {207, 871.5}”;
    UIKeyboardCenterEndUserInfoKey = “NSPoint: {207, 600.5}”;
    UIKeyboardFrameBeginUserInfoKey = “NSRect: {{0, 736}, {414, 271}}”;
    UIKeyboardFrameEndUserInfoKey = “NSRect: {{0, 465}, {414, 271}}”;
    UIKeyboardIsLocalUserInfoKey = 1;

键盘收回:
UIKeyBoardWillHideNotification
UIKeyBoardDidHideNotification

  1. UIKeyboardAnimationCurveUserInfoKey = 7;
    UIKeyboardAnimationDurationUserInfoKey = “0.25”;
    UIKeyboardBoundsUserInfoKey = “NSRect: {{0, 0}, {414, 271}}”;
    UIKeyboardCenterBeginUserInfoKey = “NSPoint: {207, 600.5}”;
    UIKeyboardCenterEndUserInfoKey = “NSPoint: {207, 871.5}”;
    UIKeyboardFrameBeginUserInfoKey = “NSRect: {{0, 465}, {414, 271}}”;
    UIKeyboardFrameEndUserInfoKey = “NSRect: {{0, 736}, {414, 271}}”;
    UIKeyboardIsLocalUserInfoKey = 1;

2.在不用的时候要注销通知发送

0 0
原创粉丝点击