0

I have created a UITextView *mytextview . I want to get event when click textview before UIKeyboardWillShowNotification delegate.

Now, When I click textview, is's call UIKeyboardWillShowNotification. After that, it's call - (void)textViewDidBeginEditing:(UITextView *)textView, it's not good!

I want to mytextview delegate was called before call UIKeyboardWillShowNotification

How to I can resolve this problem

2 Answers2

0

Use textViewShouldBeginEditing provided by the UITextViewDelegate, call your delegate method in it, and return YES from this method to let user edit the text.

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    [yourDelegate yourMethod:textView];
    return YES;
}
Sagar D
  • 2,588
  • 1
  • 18
  • 31
0

The sequence of Event execution are

  1. UIKeyboardWillShowNotification
  2. textViewDidBeginEditing

Now as per our requirement I Fire On Notification that is called when KeyBoardWillShow.

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

And in the selector I passed same function which is called after UIKeyBoardWillShown, Also you can set your Own Function, which you want to do Before UIKeyBoardShow

This is My Code

- (void)viewDidLoad {
        [super viewDidLoad];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewDidBeginEditing:) name:UIKeyboardWillShowNotification object:nil];

    }

    - (void)textViewDidBeginEditing:(UITextView *)textView {
        NSLog(@"textViewDidBeginEditing");
    }
Jatin Patel
  • 396
  • 3
  • 14