2015-11-25 51 views
-1

我創建了一個UITextView *mytextview。我想在UIKeyboardWillShowNotification代表之前點擊textview時獲得活動。IOS textView代理

現在,當我點擊textview時,是叫UIKeyboardWillShowNotification。之後,它叫- (void)textViewDidBeginEditing:(UITextView *)textView,這不好!

我想mytextview delegate呼叫UIKeyboardWillShowNotification

之前被稱爲如何,我可以解決這個問題

+0

使用' - (BOOL)textViewShouldBeginEditing:(UITextView *)textView' –

回答

0

使用textViewShouldBeginEditingUITextViewDelegate提供,請致電它的委託方法,從這個方法返回YES讓用戶編輯文本。

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView 
{ 
    [yourDelegate yourMethod:textView]; 
    return YES; 
} 
0

事件執行的順序是

  1. UIKeyboardWillShowNotification
  2. textViewDidBeginEditing

現在按照我們的要求,我火的通知時調用KeyBoardWillShow。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewDidBeginEditing:)name:UIKeyboardWillShowNotification object:nil] 

而在選擇我通過這UIKeyBoardWillShown後調用同樣的功能,你還可以設置自己的功能,你想要做UIKeyBoardShow

之前

這是我的代碼