views:

61

answers:

1

EDIT 2: I now think the best soluton is to create ListeningView.h that just includes a ListeningView protocol, instead of subclassing ListeningView (since we can't do multiple inheritance in Obj-C). Then, you still need ListeningViewController as well.

EDIT: Ok, I figured out what the approved idiom is here. I should subclass UIViewController to create ResponderViewController, which will loop through its subviews for ResponderViews when it appears/disappears. Then, any viewController that has responderViews should inherit from ResponderViewController.

=======

UIViewControllers have viewWillAppear, viewDidDisappear, etc. delegate methods.

I would like to create a UIView subclass that can be added to a viewController's view, and when that UIViewController apears or disappears, a delegate function is called.

I could easily do this by putting function calls in the UIViewController viewWillAppear/viewWillDisappear delegate functions, but how can I encapsulate this behavior in the UIView?

A: 

I wouldn't do that if I were you. All that sort of behavior should not be controlled by a view; that's just was controllers are for.

Jonathan Sterling
These views will not be fullscreen views, so I don't think I should use a UIViewController here. None of its methods would work properly to present or hide the view. If there was a class called PartialScreenViewController that could be added to a viewController and have all of its delegate methods called, that's what I'd use.
Andrew Johnson