iPhone开发--UITextView中的文字改变时触发的事件

实例化UITextVIew的类对象并将UITextView的实例对象的delegate设为self。

[cpp]  view plain copy
  1. m_contentTextField = [[[UITextView alloc] init] autorelease];  
  2. m_contentTextField.frame = CGRectMake(0, 0, 320, 90) ;    
  3. m_contentTextField.backgroundColor = [UIColor whiteColor] ;  
  4. m_contentTextField.font = [UIFont systemFontOfSize:14];  
  5. m_contentTextField.delegate = self ;       
  6. [m_contentTextField becomeFirstResponder];  

之后通过UITextViewDelegate的方法中的textViewDidChange方法来监听文字改变的消息了。

[cpp]  view plain copy
  1. - (void)textViewDidChange:(UITextView *)textView {  
  2.     NSLog(@"textViewDidChange:%@", textView.text);  
  3. }  

一定要记得在头文件中导入UITextViewDelegate哦。

附加:

该代理还实现了以下几种监听事件
– textViewShouldBeginEditing:
– textViewDidBeginEditing:
– textViewShouldEndEditing:
– textViewDidEndEditing:

哈哈。


转载:http://blog.csdn.net/zcl369369/article/details/7552003

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值