I'm seriously losing my hair because of simple task which turned to hell. So I have UIScrollView subclass – MyScrollView and UIViewController subclass StoryViewController using that scroll view. I need to know when scroll is scrolled so what do I do? I try to delegate!
// StoryViewController.h
@interface StoryViewController : UIViewController <UIScrollViewDelegate>
// StoryViewController.m
// init
scrollView = [[MyScrollView alloc] init];
scrollView.delegate = self;
// delegated function
- (void)scrollViewDidScroll:(UIScrollView *)s {
NSLog(@"TEST");
}
Edit: Some NSLogs
Self: <StoryViewController: 0xfce090>
ScrollView Delegate: <StoryViewController: 0xfce090>
WebView Delegate: <StoryViewController: 0xfb1a30>
Edit:UIWebView subclass (MyWebView) which is subview of MyScrollView works fine and (void)webViewDidFinishLoad:(UIWebView*)webView (in the same storyviewcontroller.m) prints message.
No errors, builds fine, runs fine. After scrolling – nothing gets printed.
What am I doing wrong?
Best Answer
This may be a red herring, but you're calling alloc and init, rather than alloc and initWithFrame:. I assume you're adding the scrollView in your viewDidLoad method? Is this a XIB-based controller? Have you tried adding the scrollview in the XIB file, and setting things up there? Have you tried adding other delegate methods?