我有两个UITextViews!我遇到的问题是,我想要在输入其中一个textViews而不是另一个时执行操作!我把动作代码放在
中- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
但是在输入任一文本视图时执行操作。是否有方法通知何时使用某个文本视图?
答案 0 :(得分:1)
您可以设置tag
的{{1}}来区分它们。
UITextView
答案 1 :(得分:1)
为此目的,textView作为参数传递给委托函数
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
您可以维护textview实例的属性,并且在委托调用中只需检查哪个textview接收到了触摸。
答案 2 :(得分:1)
你可以用两种方式做到这一点
首先
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
if ( textView == YourTextView )
{
// ----- do here
}
return YES;
}
第二是
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
if ( yourTextView.tag == yourTag)
{
// ----- do here
}
return YES;
}