Scrolling TTTableViewControllerToTop not working

I use the base Three20 TTTableViewController subclass, which uses its own data source and model.

The problem is that I cannot use the scrollsToTop property of the table. This is a standard property for a table, inherited from UIScrollView and very often used.

I tried all of the following, in different places / methods of my class:

self.tableView.scrollsToTop = YES;
[self.tableView setScrollsToTop:YES]


I also tried to override the method

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
    return YES; 
}

All without success.

NB. To be clear, I mean the standard gesture of clicking on the status bar to scroll up the visible table view (i.e., the first row).

Any help is much appreciated!

+3
source share
4


G , . , , init viewDidLoad.

, :

  • tableView viewDidLoad, . [[self tableView] setTableHeaderView:]

  • init/initWithStyle.

UIScrollViews , . Three20, , , .

: , - , viewDidLoad BEFORE init. viewDidLoad , , , . .

+3

Apple UIScrollView:

scrollsToTop

, ,

, scrollview, .

, UITableView:

scrollToRowAtIndexPath: atScrollPosition: :

, , , .

three20

three20, , , UITableView+Additions.h > - (void)scrollToFirstRow:(BOOL)animated

[self.tableView scrollToFirstRow:YES];

three20

three20, three20 :

- (void)scrollToFirstRow:(BOOL)animated {
  if ([self numberOfSections] > 0 && [self numberOfRowsInSection:0] > 0) {
    NSIndexPath* indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    [self scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop
          animated:NO];
  }
}

, (), UIScrollView , ( three20):

- (void)scrollToTop:(BOOL)animated {
  [self setContentOffset:CGPointMake(0,0) animated:animated];
}

:

[self.tableView setContentOffset:CGPointMake(0,0) animated:YES];
+3

:

self.tableview.scrollingEnabled=YES;
self.tableview.scrollsToTop=YES;

, YES :

scrollViewWillScrollToTop:

+1

@imnk, , .

What I'm experiencing (and just tested to be sure) is that as soon as I change the frame tableView property, touching the statusBar no longer works ...

According to the Apple Documentation in UIScrollViewDelegate, each scrollView delegate (regardless of size) can return YES on - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView.

But I looked through three20 and changed it in my delegate actions, but without success.

0
source

Source: https://habr.com/ru/post/1765806/


All Articles