I'm handling code in a UITextViewDelegate. Each function there receives the UITextView instance that received the event, for example:
- (void)textViewDidBeginEditing:(UITextView*)textView { }
Inside that method however, only given the textView, I need to access the UIViewController that contains the textView.
Using textView.superview
(even multiple stages of it) doesn't seem to work - I only get:
- textView.superview = an instance of UIView
- textView.superview.superview = UIViewControllerWrapperView
- textView.superview.superview.superview = UINavigationTransitionView
- textView.superview.superview.superview.superview = UILayoutContainerView
- textView.superview.superview.superview.superview.superview = UIWindow
- textView.superview.superview.superview.superview.superview.superview = nil
I found the class names by printing out something like
printf( "class: %s\n", [[[uiv class] description] UTF8String] ) ;