I have a UIScrollView
that I need to subclass and within the subclass I need to attach the UIScrollViewDelegate
so I can implement the viewFo
Short answer: you don't. Delegates are typically a weak one-to-one relationship:
@property (nonatomic, weak /*or assign*/) id delegate;
Sometimes you will see a "listener" design pattern, which is the one-to-many form of delegates:
- (void) addListener:(id)listener;
- (void) removeListener:(id)listener;
In your case, there doesn't appear to be a nice public override point in UIScrollView that allows subclasses to specify the viewForZoomingInScrollView. I would avoid making the UIScrollView its own delegate, if possible. You could make the UIViewController the UIScrollViewDelegate and have it provide the viewForZooming. Or you could make an intermediate view subclass which uses UIScrollView, provides the viewForZooming, and forwards the other delegate methods up.