Objective-c – Wiring events to a UITextView

eventsiphoneobjective cuitextview

I can't seem to wire events to my UITextView.

I'm expecting that the list of events that are available for the UITextField ("Did End On Exit", "Editing Changed", etc) , should all be available for the UITextView.

However this isn't the case. UITextView in its events listing shows nothing.

What's going on here and how do I trap events for UITextView?

Best Answer

Your view controller will need to implement the UITextViewDelegate.

@interface SaveGameViewController : UIViewController<UITextViewDelegate>  

After you add the UITextViewDelegate to your view controller, open Interface Builder, and you can find this "delegate" hook under the First Owner.

In my case, I have a text view within a SaveGameView that is the view of SaveGameViewController and, when open my SaveGameViewController.xib in IB, I can wire the text view to delegate within First Owner so that the view controller will respond to the delegate event:

-(IBAction)textViewDidBeginEditing:(UITextView *)textView;

This method is also within SaveGameViewController