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];   

    }

  • 相关阅读:
    请假两时间的小时数差
    Python3之旅
    python语法总结1
    关于命令行的小结
    从Java到C#再到python
    数据库知识
    Visual Studio高低版本的问题(以2008和2015为例)
    web api
    readoney和const
    null
  • 原文地址:https://www.cnblogs.com/damonWq/p/5229706.html
Copyright © 2011-2022 走看看