I’m new to Objective C in general, and am having trouble finding useful docs with step by step examples like the django project (best docs in the world!).
I could find endless resources on building UIScrollViews through the Interface Builder, but not programmatically.
My biggest hurdle was: How do I subclass a UISCrollView method call (like viewForZoomingInScrollView) if I’m not using a UIScrollView class?
You simply need to set the delegate for the scrollView to point to whichever class HAS those methods.
Example:
// in my .m file
-(void)loadView {
CGRect fullScreenRect = [[UIScreen mainScreen] applicationFrame];
scrollView = [[UIScrollView alloc] initWithFrame:fullScreenRect];
scrollView.delegate = self;
self.view = scrollView;
}
// now my scrollView is loaded and ready to be populated with a scrollable subframe in viewDidLoad
// because the delegate has been set to 'self', these methods will be called despite this class not being a UIScrollView subclass.
-(UIView*)viewForZoomingInScrollView:(UIScrollView*) scroll {
return imageView;
}
Thank you! I was searching for it for a long time!