Pass scroll between UIScrollView and embed UICollectionView - ios

Here's my architecture.
I have a UIScrollView with some UIView's added in.
At the end on my scrollview i have a UICollectionView (embedded in my scrollview) in which i loads many data. I had to use a UICollectionView in order to reuse the multiple views displayed.
What i want is keep a smooth scroll when the user scrolls to the bottom of the parent scrollview and continue scrolling in the UICollectionView.
What i've made now is set the size of my UICollectionView equal to my UIScrollView Size and i've disabled bounces on both.
But i can't have a smooth scroll. When i reach the end of my UIScrollView, the scrollview's stop and then i have to re scroll on my UICollectionView
Not sure if it's really clear.

You should not normally "pass scroll" between elements. What you need to make sure is that the UICollectionView's frameSize is equal to its contentSize, meaning its frameSize expands as much as its contents so that all of its content is visible without having to scroll. Then your UIScrollView will handle the scroll and show the contents of your UIViewController by scrolling just itself.

Related

How to embed scrollview to tableview cell?

I have a scrollview embedded in a cell of tableview. The scrollview is a Foxit PDF rendering engine.
I want to scroll vertically the tableview, horizontally the scroll view. I couldn't. As on the first GIF you see scrollview is bouncing even the content height and scroll height is equal. But at least paging is possible.
Then I added a custom scrollview over the Foxit view into the cell. The bouncing disappeared and scrolling up and down the scrollview scrolls the table view. That is good. But now I can not horizontally scroll and change pages of the PDF.
What to do how to "merge" the two approach?
Try to play with panGestureRecognizer of scrollView and tableView. Install a relationship to prevent scrollView getting gestures before tableView scrollView.panGestureRecognizer.require(toFail: tableView.panGestureRecognizer).

UITableView inside UIScrollView - Cell not clickable

I have a problem with a UITableView not detecting touches.
In an iPhone-only app, I have a UIViewController, which containts:
UIScrollView
UIView (let's say a content view)
Some labels
UITableView (last)
The labels have a dynamic height, because they contain some text that I must retrive from the web, so I'm using auto layout.
I'm setting the content size of the UIScrollView inside the viewDidLayoutSubviews method, and I'm doing this by summing UITableView.frame.origin.y and its height.
Here comes the problem: when the labels contain only some words and the UITableView does not exceed the iPhone screen size, everything works ok. But when they grow, and the UITableView gets pushed down, when I scroll down I can't click on the cell anymore. Also, if when loading the view the table is half visible and half not, I can click the visible cells, but if I scroll down, I can't click the others.
I'm using swift 2 and Xcode 7.
Here is an example:
Clickable:
Unclickable:
Do the following thing:
yourView.clipToBounds = true
Now, if UITableView does not appears means your UIView is not same bigger to hold down UITableView.
Make sure that your UIView height is bigger to hold the contents in it and then try to tap on it.
Updated:
If you are using AutoLayout, then do the following thing.
Give the fix height to UIView
Take the outlet of height constraint of UIView
Now, in viewDidLayoutSubviews change the constraint of UIView to UITableView contentSize height.
self.heightConstraint = self.tableView.contentSize.height
Let me know, if this helps!
Adding some info to the #Rémy Virin's answer here:
From Apple Documentation, you shouldn't embed a UITableViewinside a UIScrollView.
Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
Addition:Solution Since you want to scroll the content above table also, the one solution is place a Header View for the Table and place the Content over there to make it Scroll along the Table View.
If you use Autolayout, no need to specify contentSize to UIScrollView as it will automatically expand by taking the height of its subview.
In your case, increase the height of the Base UIView (content view as mentioned by you) which holds the tableView when the tableView height increases.
UITableView becomes unresponsive when it extends below its container view.

Scrolling issue when UITableView is inside ScrollView

I have a UIScrollview covering the entire UIViewController's main view. Inside UIScrollview is a content view that allows the UIScrollview get the scrollable content. Inside the Content View of Scroll View is a UITableView.
I'm not being able to scroll the UITableView. Instead the vertical swipe is passed directly to the ScrollView causing it to scroll. How can I make the UITableView scroll inside the UIScrollview?
I have read the answers of many similar questions but none of them solved my issue
Question 1
Question 2
Question 3
You need to set correct constraints (or frames) for UITableView (size of TableView must be less, then contentSize for scrolling).
Make sure that's your constraints of UITableView related to UiScrollView
Disable UITableView scrolling
Make your scollView center Verticly to the main container and change the priority of constraint to 999
Hope that help you

Putting a UIScrollView inside a UIPageView, scrolling doesn't work

I'm making a pageview that has a bunch of scrollable pages inside it. I have the pageview working, and the viewcontrollers that it rotates each have a scroll view inside them. The problem is, I think, that the scrolling doesn't happen because the touches don't get through to the pageview. The scroll view should only scroll vertically, while the pageview works with the horizontal scrolling. Is it possible to send through only the vertical touches, or is there another way?
Thanks
If you're using a storyboard, open the Attributes inspector of the embedded UIScrollView and deselect the "Shows Horizontal Indicator" option. Do the same on the UIPageViewController, but for the "Shows Vertical Indicator". However, you also have to ensure that the scroll view's contents aren't wider than the scroll view itself; to do this, just constrain the contents' width to be equal to the scroll view's parent.

UIScrollView in UITableView Header not scrolling

Following problem: I have a UITableView with several cells. The table has also a header, in which i added a UIScrollView, which should scroll horizontal.
So now when i scroll around the screen the table will always be scrolled, but not the UIScrollView in the header, even if i scroll horizontal in the area of the header.
So it seems the table is managing all the scrolling. How can i setup the UITableView scrolling so that the UIScrollView in the header handles the horizontal scrolling for the header area.
I tried to set delegate of the UIScrollView and tried the function from the UIScrollViewDelegate, - (void)scrollViewDidScroll:(UIScrollView *)scrollView, but only the table calls this function.
I hope you can help me.
Set content Size properly. Content size should be the width and height till where you want to scroll.
scrollView.contentSize=CGSizeMake(100,960);

Resources