未调用 UITextView shouldChangeTextInRange 委托 [英] UITextView shouldChangeTextInRange delegate not called
本文介绍了未调用 UITextView shouldChangeTextInRange 委托的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码来设置视图中的 uitextview 的参数.
I am using this code to set the parameters of an uitextview i have on my view.
_textview=[[UITextView alloc]init];
[_textview setUserInteractionEnabled:FALSE];
_textview.text=@"Write your message";
_textview.textColor=[UIColor lightGrayColor];
_textview.layer.cornerRadius=6;
_textview.contentInset = UIEdgeInsetsZero;
_textview.delegate=self;
我在 .h 中有这个代码
I have in the .h this code
IBOutlet UITextView *_textview;
@property(nonatomic,retain) IBOutlet UITextView *_textview;
我已经使用接口将插座连接到 uitextview.
I have connected the outlet to the uitextview by using the interface.
发生的情况如下:
- (void)textViewDidChange:(UITextView *)inTextView
上面的委托被调用,但不是下面的委托:
the above delegate is called but not the following one:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementString:(NSString *)string
为什么会这样?我做错了什么吗?
Why is this happening? Am i doing something wrong?
感谢任何帮助...
推荐答案
除了删除 _textview = [[UITextView alloc]init];
以免覆盖你的笔尖加载的 textview.
In addition to removing the _textview = [[UITextView alloc]init];
so as to not overwrite your nib loaded textview.
方法是:
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{}
正确的方法签名是:
textView:shouldChangeTextInRange:replacementText:
不是:
textView:shouldChangeTextInRange:replacementString:
这篇关于未调用 UITextView shouldChangeTextInRange 委托的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文