cross scrolling: tableview inside UIpageViewcontroller does not behave properly - ios

In my app, I have a UIPageViewcontroller. Inside the UIPageViewcontroller, I have a Viewcontroller with a table inside of it.
The problem I am having is, when I am scrolling down the table, I can't scroll between pages. unless I lift my finger up. (this also has to make sure that table stops scrolling completely)
I was hoping there would be a more natural way of doing this.
Is there a way to swipe between pages even when your scrolling down the table, without have to lift up your finger

I just tried Instagram, they have same UI as you are trying to achieve.
When I scrolled through Insta posts, I could not Swipe between View Controllers until table scroll stops.
1 option you can do is to reduce the speed of table scroll using following code:
self.tableview.scrollView.decelerationRate = UIScrollViewDecelerationRateFast;
This code will allow table to stop quickly and hence user can swipe.
Hence, I would say, it is not possible to swipe between view controller unless table scrolling is stopped.

Related

Infinitely scrolling paging scrollview

My UIScrollView has 3 pages, with a separate UIView on each page. This is set up using auto layout. When the app launches, there is one view offscreen to the left, another that is onscreen, and a third offscreen to the right.
When the user pages to either side, there will be one view onscreen, with two views offscreen on the same side. What I want to be able to do is move the view furthest offscreen to the other side of the scrollview, to make it so that the scroll view can page infinitely.
I tried changing the constraints in scrollViewDidEndDragging(_:willDecelerate), but this approach is not working.
Is this effect plausible? If so, how can I achieve this effect?
Edit: One reason the approach before doesn't work is because the user can scroll past the paging without this delegate method being called. I am currently trying to see if the didScroll method will allow for the effect I am going for, but I haven't gotten this to the point where I can test it yet.

multiple view controllers with tableview inside scrollview

I have 3 viewcontrollers inside a UIScrollView that page horizontally. each viewcontroller has a tableview within it.
I can swipe between the 3 viewcontrollers easily when the active table is still (not scrolling) - but when i try to page left or right when the tableview is moving it seems to ignore the touch and gets stuck. I have to stop the tableview with a touch before paging (almost as if the tableview is trying to receive the horizontal gesture)
how can I make my scrollview always react to a horizontal paging
here is a visual of my setup:
tell me if you need any more info
There are multiple ways to get around this.
One way is that you could manage the horizontal scrolling yourself with UIGestureRecognizer. So if there is a left swipe then scroll horizontally to the left and vice versa for right swipe. That way if a UITableViewController is vertically scrolling at the time of the horizontal swipe, it won't have to wait until it is stopped to detect it.

How to enable UIPageViewController's page scroll while scrolling its content vertically (a collection view)?

I'm making an app like SmartNews, with a UIPageViewController that contains many UICollectionView pages.
The structure:
A UIPageViewController, with pages scrolling horizontally. (Transition style is UIPageViewControllerTransitionStyleScroll)
Each page in it contains a UICollectionView scrolling a set of cells vertically.
Both view have the same size and touch areas on the screen are common.
The problem:
While the collection view is scrolling down by itself (i.e. the user is no longer touching the screen but the collection view is still scrolling by decelerating), the user can't swipe pages.
It seems if another pan gesture occurs at this moment, it is tracked by the collection view to stop the current scroll and it doesn't allow the user to swipe the page view controller.
Is there a way to allow the user to scroll pages (horizontally), while the collection view is still scrolling (vertically)?
(Instagram's search view realizes this feature.)
Thanks!
Found what I wanted to do here:
Cross Directional UIScrollViews - Can I Modify the Scrolling Behaviour?
I guess it's unsafe to do the same with UIPageController as the scroll view inside it is undocumented.
I will try to replace the UIPageController with a UISCrollView with paging enabled.

UITableViewCell Editing is very difficult to show

I want my table view cell to show the Delete bar on the right side when the user swipes. However, the table view is in a UIScrollView, and although it is at the far right side, and swiping left does not move the scroll view, the table view cell makes it difficult to edit.
In order to trigger the swipe for editing, I must swipe very fast and in a perfectly horizontal line. The speed required is far more than you can expect users to even want to do, and would not be expected at all from a user's perspective.
I believe the scroll view is the cause, but I cannot be certain. No gesture recognizer is present.
How can I prevent the scroll view from mucking up this experience?
Putting a tableView or webView in a scrollView is not advised, because of the exact problem you are having. Your best bet is to find a way around putting it in a scrollView. Other than modifying your tableView to not be in the scrollView, you might try moving your tableView to the front. [superView bringSubviewToFront:tableView]; hope this helps.
You could try using the gesture recognizer delegate methods for this. I don't have Xcode in front of me, but if you use gestureRecognizer:shouldRequireFailureOfGestureRecognizer: and just fail the scrollView's swiping gesture if the gesture recognized is that of the swiping of the table view cell. Check UIGestureRecognizerDelegate in the docs.

Adding a Scrolling Subview to a UITableView (NOT a Cell)

I'm creating my views programmatically. I have a UITableView in my UIViewController subclass that I want to add a scrolling subview to that is not a cell. I want to add some text-based subview to the UITableView that scrolls with the table and starts out above y=0 so the user will only see it if he pushes the table down. That is, it should reside above the first section of my table. If it helps for visualization, I intend to make something similar to those "scroll down to refresh" features and want some indication to the user that scrolling down causes a refresh. Is there any way to do this without something messy like using another UITableViewCell to represent it or abusing the UITableView delegate methods to move a view around whenever the user scrolls?
Simply using [tableView addSubview:] in my viewWillLoad only makes it appear for a split-second then disappear once the table data is loaded. This seems weird to me because UITableView is a subclass of UIScrollView, which is meant to hold other views in it. Using [tableView.backgroundView addSubview] does nothing.
P.S. Why not use a UIRefreshControl for this? I'm still undecided but leaning towards not using one because I don't like how slow that spinning wheel "feels" when the refreshes are usually very very quick. I've been looking at other options like flashing the background subtly and only showing a wheel if it's taking a longer time than usual.
I You can implement pull to refresh with only a table view
To do this using the scroll view delegate, since tableview is a subclass of scroll view.
Set view controller to be the tableview delegate and implement
(void)scrollViewDidScroll:(UIScrollView *)scrollView
When scrollview content offset y value passed a point, add a label to the viewcontroller.view not tableview. When you scroll back or release, remove the view.
You might also be able to add label to the table view and set the frame origin to negative y value, so when you pull the label will move into view (Never tested this do might not work)

Resources