evadne / RAPageViewController

Sliding pages side by side, infinitely. Fancy parts from the redacted bits, re-implemented for expressiveness at expense of some naïvety
77 stars 5 forks source link

Attempt to make "tap status bar to scroll" work. It does, but in my test... #7

Closed stuffmc closed 11 years ago

stuffmc commented 11 years ago

...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.

evadne commented 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

have a look.

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:

stuffmc commented 11 years ago

So is it still around? :-)

mbbischoff commented 11 years ago

:+1:

stuffmc commented 11 years ago

FYI: https://gist.github.com/stuffmc/5271713

evadne commented 11 years ago

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.

evadne commented 11 years ago

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;

    }
stuffmc commented 11 years ago

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.

evadne commented 11 years ago

@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.

evadne commented 11 years ago

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.)

stuffmc commented 11 years ago

How are we doing on pulling 0d8d1ce? :-)

evadne commented 11 years ago

Pulled in.

stuffmc commented 11 years ago

Thanks