Closed stuffmc closed 11 years ago
I fixed this once with Abraham Vegh’s help (it was an off-hand tweet) and it is in one of my internal projects. Maybe it is still around.
On Mar 22, 2013, at 5:04, StuFF mc notifications@github.com wrote:
...s with a NavigationController only when first pushing then popping. The basic problem is that there can only be one tableView having "scrollsToTop" for this to be called by iOS. Hope @evadne https://github.com/evadne can
You can merge this Pull Request by running
git pull https://github.com/stuffmc/RAPageViewController develop
Or view, comment on, or merge it at:
https://github.com/evadne/RAPageViewController/pull/7 Commit Summary
File Changes
Patch Links:
So is it still around? :-)
:+1:
Hey, we should just tell the page view controller’s internal scroll views to not scroll to top, either by default or from your app. Tickling UIScrollView.scrollsToTop
and setting it to NO internally should do the trick. Push the responsibility to the client.
I believe that this is the diff that will work in this case.
:+1: :question: :-1: :question:
diff --git a/RAPageViewController/RAPageCollectionViewController.m b/RAPageViewController/RAPageCollectionViewController.m
index 263a6f2..cb6eb86 100644
--- a/RAPageViewController/RAPageCollectionViewController.m
+++ b/RAPageViewController/RAPageCollectionViewController.m
@@ -88,6 +88,7 @@
_collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_collectionView.pagingEnabled = YES;
_collectionView.clipsToBounds = NO;
+ _collectionView.scrollsToTop = NO;
// If you change the scroll direction later, you’re responsible for twiddling the bouncy bits
diff --git a/RAPageViewController/RAPageViewController.m b/RAPageViewController/RAPageViewController.m
index 5b1d0e4..fe41806 100644
--- a/RAPageViewController/RAPageViewController.m
+++ b/RAPageViewController/RAPageViewController.m
@@ -67,6 +67,7 @@
_scrollView.alwaysBounceVertical = NO;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
+ _scrollView.scrollsToTop = NO;
}
Won't work unless you also set "scrollsToTop" to NO to the other scrollViews (in my case) tableViews inside this scrollview. This is what I do in the gist.
@stuffmc I think this responsibility will be pushed to the client. We already have UIScrollView
, UITableView
and UICollectionView
to worry about, and we can’t second guess view hierarchies provided by consumers of this class. It might be better to just document it instead of pushing in a 80% solution. Meanwhile the page view controller can self-censor.
Also, would love to look at your app / reduced sample with multiple tables. If I’m guessing correctly you’re doing horizontal pages, each an UITableViewController
. If that is the case, you’ll want to listen for page changes, and only set scrollsToTop
to YES
for the scroll view (in this case, an UITableView
) on the current page.
By default that means the table view controllers you vend shall have scrollsToTop
disabled by default and preferably re-set it on -viewWillAppear:
which should work nicely with the collection view variant.. (The non-collection view variant is deprecated and will be removed; if you need to support old iOS versions, please start testing on PSTCollectionView
.)
How are we doing on pulling 0d8d1ce? :-)
Pulled in.
Thanks
...s with a NavigationController only when first pushing then popping. The basic problem is that there can only be one tableView having "scrollsToTop" for this to be called by iOS. Hope @evadne can have a look.