iPhone开发--UITextView中的文字改变时触发的事件
2015-02-09 09:54
316 查看
实例化UITextVIew的类对象并将UITextView的实例对象的delegate设为self。
[cpp] view
plaincopy
m_contentTextField = [[[UITextView alloc] init] autorelease];
m_contentTextField.frame = CGRectMake(0, 0, 320, 90) ;
m_contentTextField.backgroundColor = [UIColor whiteColor] ;
m_contentTextField.font = [UIFont systemFontOfSize:14];
m_contentTextField.delegate = self ;
[m_contentTextField becomeFirstResponder];
之后通过UITextViewDelegate的方法中的textViewDidChange方法来监听文字改变的消息了。
[cpp] view
plaincopy
- (void)textViewDidChange:(UITextView *)textView {
NSLog(@"textViewDidChange:%@", textView.text);
}
一定要记得在头文件中导入UITextViewDelegate哦。
附加:
该代理还实现了以下几种监听事件
– textViewShouldBeginEditing:
– textViewDidBeginEditing:
– textViewShouldEndEditing:
– textViewDidEndEditing:
哈哈。
转载:http://blog.csdn.net/zcl369369/article/details/7552003
[cpp] view
plaincopy
m_contentTextField = [[[UITextView alloc] init] autorelease];
m_contentTextField.frame = CGRectMake(0, 0, 320, 90) ;
m_contentTextField.backgroundColor = [UIColor whiteColor] ;
m_contentTextField.font = [UIFont systemFontOfSize:14];
m_contentTextField.delegate = self ;
[m_contentTextField becomeFirstResponder];
之后通过UITextViewDelegate的方法中的textViewDidChange方法来监听文字改变的消息了。
[cpp] view
plaincopy
- (void)textViewDidChange:(UITextView *)textView {
NSLog(@"textViewDidChange:%@", textView.text);
}
一定要记得在头文件中导入UITextViewDelegate哦。
附加:
该代理还实现了以下几种监听事件
– textViewShouldBeginEditing:
– textViewDidBeginEditing:
– textViewShouldEndEditing:
– textViewDidEndEditing:
哈哈。
转载:http://blog.csdn.net/zcl369369/article/details/7552003
相关文章推荐
- iPhone开发--UITextView中的文字改变时触发的事件
- iOS开发中Swift3 监听UITextView文字改变的方法(三种方法)
- 【UNITY3D 游戏开发之八】Unity编译到iPhone运行 Collider 无法正常触发事件解决方案
- iPhone开发--光标定位到含有文字的UITextVIew的首位置
- 【UNITY3D 游戏开发之八】Unity编译到iPhone运行 Collider 无法正常触发事件解决方案 推荐
- 开发日志:js当文本框输入非中文字符时,提示只能输入中文并将非中文字符清空【兼容IE、FF,适用于当文本框内容改变就立刻触发事件的其他功能性需求】
- 移动端开发注册、登陆input常用事件(input输入文字触发事件)
- 【UNITY3D 游戏开发之八】Unity编译到iPhone运行 Collider 无法正常触发事件解决方案
- 窗口大小改变触发Event.RESIZE事件
- .C# 获取另一程序控件,改变值,触发事件
- iPhone开发指南-事件处理
- 【Cocos2d游戏开发之六】对触屏事件追加讲解,解决无法触发ccTouchMoved事件[重要!]
- iPhone开发进阶(8)--- 检测屏幕触摸事件
- iphone开发之触发振动和获取用户电话号码
- 【iOS-Cocos2d游戏开发之六】对触屏事件追加讲解,解决无法触发ccTouchMoved事件[重要!] 推荐
- iPhone开发指南-事件处理
- javascript 动态改变onclick事件触发函数代码
- iphone开发之触发振动和获取用户电话号码
- javascript改变asp:textbox的值,如何触发OnTextChanged 事件
- extJs 文本框后面加上说明文字+下拉列表选中值后触发事件