iPhone开发--UITextView中的文字改变时触发的问题
发布时间:2021-11-23 14:05:11 所属栏目:PHP教程 来源:互联网
导读:实例化UITextVIew的类对象并将UITextView的实例对象的delegate设为self。 m_contentTextField = [[[UITextView alloc] init] autorelease]; m_contentTextField.frame = CGRectMake(0, 0, 320, 90) ; m_contentTextField.backgroundColor = [UIColor whiteCo
实例化UITextVIew的类对象并将UITextView的实例对象的delegate设为self。 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方法来监听文字改变的消息了。 - (void)textViewDidChange:(UITextView *)textView { NSLog(@"textViewDidChange:%@", textView.text); } 一定要记得在头文件中导入UITextViewDelegate哦。 附加: 该代理还实现了以下几种监听事件 – textViewShouldBeginEditing: – textViewDidBeginEditing: – textViewShouldEndEditing: – textViewDidEndEditing:linux (编辑:云计算网_泰州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |