zoukankan      html  css  js  c++  java
  • 0301——Notification 通知

    注册消息

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(方法) name:@"消息名字" object:nil];

    方法实现

    -(void)方法:(NSNotification *)notfication{

        //获取传递的数据

        NSDictionary * dataDic = notfication.object; 

    }

    发布消息

    [[NSNotificationCenter defaultCenter]postNotificationName:@"消息名字" object:传回的东西];

     

    键盘的消息使用

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyBoardDidChanged:) name:UIKeyboardWillChangeFrameNotification object:nil];

    方法实现

    -(void)keyBoardDidChanged:(NSNotification *)notifi{

        //可以先打印notifi开看看有什么消息名字

        CGRect endRect = [[notifi.userInfo objectForKey:@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];

        ......//屏幕在键盘改变的时候重新布局

        [self.view layoutIfNeeded];   

    }

  • 相关阅读:
    MVC知识点01
    MVC知识点02
    ADO.NET基础01
    WinForm,MVC知识点
    C#基础01
    28、对多次使用的RDD进行持久化或Checkpoint
    27、优化数据结构
    26、高性能序列化类库
    25、诊断内存的消耗
    24、Checkpoint原理剖析
  • 原文地址:https://www.cnblogs.com/damonWq/p/5229706.html
Copyright © 2011-2022 走看看