Zuzana Paulis
Zuzana Paulis

Reputation: 951

UITableView scroll jumps

Recently my app started doing scroll jumps when new ViewController was pushed like so:

UITableViewController scroll jumps

I have tried different answers but nothing seems to work. I have learned that my app was setting negative offset to CGPointZero after I have set:

- (void)viewWillDisappear:(BOOL)animated {

[super viewWillDisappear:animated];

self.tableView.scrollEnabled = NO;

}

I have tried to find what was setting the offset and I have learnt that setContentOffset it was invoked from:

UIScrollViewInternal _adjustContentOffsetIfNecessary.

Upvotes: 0

Views: 882

Answers (2)

Zuzana Paulis
Zuzana Paulis

Reputation: 951

All the answers that I found about this topics where suggesting to set:

self.automaticallyAdjustsScrollViewInsets = NO;

It did not work and it was driving me mad. Than I came across the answer suggesting the view hierarchy as the cause of some offset problems.

enter image description here

I was desperate so I tried moving this debug button from the top of the hierarchy like so:

enter image description here

weird jumping stopped.

Later I have learnt that your tableView should always be at the beginning of the view hierarchy so the autoadjustscrollinsets feature work properly and I have added:

[self.view sendSubviewToBack:self.tableView];

Just to be sure it always is because apple does not guarantee that it would not fiddle with .xibs hierarchy.

Upvotes: 1

mengkeer
mengkeer

Reputation: 11

maybe you need to add the following code Settings to your UITableView

self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

Upvotes: 0

Related Questions