1
我想要關閉鍵盤,當用戶在uitextview
上單擊時以及他處於編輯模式時。有誰知道這是怎麼做到的嗎?uitextview在編輯模式下的單個選項卡,關閉鍵盤
touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
未被解僱。
雖然我不能使用textViewDidBeginEditing
。
已將UITextViewDelegate
包含在我的頭文件中。在.m文件,我已經設置了委託作爲self.textView.delegate = self
以下是代碼捕捉觸摸事件
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
if([self.textView isFirstResponder])
{
[self.textView resignFirstResponder];
}
}
但它是沒有得到通過,我使用TextView的調用。
我假設你在iPhone上談論objective-C?你嘗試過哪些代碼,你在哪裏掙扎? –
在我的頭文件中包含了UITextViewDelegate。 在.m文件, 我已經設置了委託作爲self.textView.delegate =自我和下面是代碼捕捉觸摸事件 - (無效)的touchesBegan:(NSSet中*)觸摸withEvent:方法(的UIEvent *)事件 { [super touchesBegan:touches withEvent:event]; if [[self.textView isFirstResponder]) } } 但它沒有被我正在使用的textView調用..可能是什麼原因? –
這一次我爲你做了,但下次請:使用你的問題下的「編輯」按鈕添加所有相關的和新的數據/代碼/信息。據我所知,必須有更多的代碼供你使用,因爲你提到了一些不在給定代碼中的變量。 –