zoukankan      html  css  js  c++  java
  • 关于UITextView的textViewDidChange回调没有调用的问题解决

    最近在做一个需求的时候,出现了这样一个问题:textViewDidChange当程序中给UITextView赋值的时候,是不被调用的,如官方文档对该方法的说明:

    Tells the delegate that the text or attributes in the specified text view were changed by the user.
    The text view calls this method in response to user-initiated changes to the text. This method is not called in response to programmatically initiated changes.

    如果必要在程序中给UITextView赋值又希望有相应的动作的话,我采用了一个替代方案:

    1.在合适的地方注册一个系统的通知(注意name,系统定义的):

           [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChangedExt:) name:UITextViewTextDidChangeNotification object:nil];

    2.实现textChangedExt:

    - (void)textChangedExt:(NSNotification *)notification

    {

     //todo sth...

    }

  • 相关阅读:
    iptables命令参数简介
    在linux下开启IP转发的方法
    Linux配置IP路由
    NAT转换
    JS实验案例
    Ubuntu kylin优麒麟root用户与静态网络设置
    非对称加密-RSA
    对称加密-DES
    DM5详解
    Visio的安装教程
  • 原文地址:https://www.cnblogs.com/Peterahan/p/3026130.html
Copyright © 2011-2022 走看看