I’m new to iOS development so this should probably be a easy question for someone.
I am creating a scrollview (tried different ways, UIScrollView, UITableView, UITableViewController) and everytime i scroll down it scrolls back up to the top automatically. Why does this happen?
I understand “scrollsToTop” is listening for some guesture to scroll to top but that is set to NO so should not be that.
“pagingEnabled” have been tested to be YES and NO but does not have an impact.
Tried to implement a UITableViewDelegate and override the scrollViewShouldSrollToTop function and return NO but the function is never called even though it is set as delegate of the tableView.
@interface Scroller : NSObject<UITableViewDelegate>
@implementation
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView )scrollView {return NO;}
// Did finish launching application
tableView = [[UITableView alloc] initWithFrame:tableRect style:UITableViewStyleGrouped];
self->tableView.pagingEnabled = NO;
tableView.scrollsToTop = NO;
[tableView setScrollsToTop:NO];
static Scroller s = [[Scroller alloc] init];
tableView.delegate = s;
Dont mind the formatting. It’s all a mess.
tableView belongs to the application delegate and is called in the ..didFinishLaunchingWithOptions:… function.
I have a breakpoint in the Scroller function “scrollViewShouldScrollToTop” but it is never hit.
I use UIScrollView instead of UITableView and set the contentSize to something bigger then the view frame and then it works. Still don’t know what the problem with UITableView is though.