I’m using a basic Three20 TTTableViewController subclass which employs its own datasource and model.
The problem is that I cannot seem to use the scrollsToTop property of the table. This is a standard property for the table, inherited from UIScrollView and very commonly used.
I have tried all of the following, in numerous different locations/methods within my class:
self.tableView.scrollsToTop = YES;
[self.tableView setScrollsToTop:YES]
I have also tried overriding the method
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
return YES;
}
All without success.
NB. To be clear, I am referring to the standard gesture of tapping on the status bar to scroll a visible table view to the top (i.e. first row).
Any help much appreciated!
Thanks to Vincent G for pointing me in the right direction. It appears that the issue is to do with what code is called in the class’s init and viewDidLoad methods.
I discovered that under the following conditions, two tableviews are added as subviews of the view controller’s view:
Making reference to the property tableView in the viewDidLoad method, e.g. [[self tableView] setTableHeaderView:]
Building the dataSource of the table within the init / initWithStyle method.
With two UIScrollViews present, the scroll-to-top action does not work properly, as Vincent pointed out. I will file these findings as a bug with the Three20 guys but by following these steps it can at least be avoided for now.
Edit: It seems that this maybe due to the viewDidLoad method being called BEFORE the init in some cases. If reference is made to the tableview in the viewDidLoad, before it has been created, I think the class is creating one. The init will then make another one.