views:

270

answers:

2

I made a custom UITableView subclass and implemented this:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    // scrolled...
}

Now, what I think is that UITableView may also love to get this message for some obvious reasons. However, when I don't forward that to super, for some reason, everything still works fine. Must I forward that guy to super? I mean...it's a delegate method implementation, but as far as I'm aware of, this would still override anything implemented in UITableView, or not?

Edit: I see...the delegate could be anyone. Never mind about this. BUT: What I have such a thing in a superclass, and make a subclass. How would I even know that the superclass does implement that method and I must forward it to super?

+1  A: 

This is a delegate method which means it gets called by your instance of UITableView for your convenience.

The scrolling happens and the UITableView internal code will call.

if ([delegate respondsTo:@selector(scrollViewDidScroll:)]) {
    [delegate performSelector:@selector(scrollViewDidScroll:) withObject:[self scrollView]];
}

And so you use this method to implement additional functionality, for example activating a control when the tableView has scrolled a certain amount.

Hope this helps!

adam
+2  A: 

Short answer: no.
Those methods are defined in the UIScrollViewDelegate Protocol.
They are meant to be implemented in a delegate, which maybe only has NSObject as parent.

It does not override anything, as it's a delegate method.
The UIScrollView just does it's stuff, and calls the delegate method if a delegate is set.

Macmade