UIScrollView behavior is different in iOS8 - ios

I have the following layout
So it's basically a scroll view that occupies whole screen. Content size is set to triple-width and same height. Inside the scroll view - there is container view and three table views - one per page. Only middle table view is visible initially.
This allows me to use scroll view horizontal scrolling to navigate between the tables and vertical scrolling inside the middle table.
I know that Apple doesn't really recommend putting UITableView inside UIScrollView, but in this particular case I don't know how to implement it differently, and until iOS8 everything was working fine.
UIScrollView would not recognize any vertical scrolling (since content height was equal to scroll view height) and these gestures were passed directly to UITableView.
But starting in iOS8 - this getting broken. UIScrollView would allow some vertical scrolling and basically intercept scrolling gestures sent to UITableView.
I created a simple project that works fine in iOS7 but is broken in iOS8. Anybody has any idea how to fix this problem?
Link to the project: https://dl.dropboxusercontent.com/u/6402890/TablePaging.zip

I haven't been able to solve this and as I mentioned in comments had to re-write logic using built-in UIPageViewController class.

If I change the Class of your ScrollView in Interface Builder to UIScrollView, it fixes part of the problem. Now just the UITableView goes up and down, and I go left-and-right, but haven't gotten rid of the space at the top.

Related

One of my UICollectionViews is not scrolling or responding to touch events inside my UIScrollView container [Puzzling]

I have an unusual and challenging problem. I have researched deeply on StackOverflow and have been unable to find any solutions. Please do not ask about my design style- it must be this way.
I have a UIPageViewController that contains a UIScrollView which contains 4 UICollectionViews. Each of these collection views should be horizontally scrollable but not vertically scrollable. The scroll view is necessary because the screen is not large enough to display all 4 collection views. Upon loading the screen, the 4th collection view is not immediately visible. After scrolling down, the 4th collection view then becomes visible.
The problem I am having is the 4th collection view does not respond to touches. Specifically, it does not respond to taps or attempts to scroll. The other 3 work perfectly fine. What makes this puzzling and odd is that the 4th one is exactly the same as the other 3, the delegate and data source are set properly and user interaction is enabled. The only real difference between the problematic collection view and the others is that it is not immediately visible when the screen loads.
When I attempt to scroll it behaves as if I am trying to change the page, so the UIPageView changes the page. So the CollectionView isn't registering any touches at all. I have a hunch that it either has to do with the GestureRecognizer from the PageView or something to do with how it isn't visible on the screen upon the initial load.
Any thoughts?
Not 100% sure without seeing the initialization of code or storyboard, but the best thing is that maybe there is a view overlapping. You can run your program and click on the 2 overlapping rectangles. This is the Debug View Hierarchy. It shows you your current frame on your phone and you can see the view laid out in hierarchal status.
Solved my own problem thanks to impression7vx's mention of the Debug View Hierarchy. Had no clue this existed but it let me discover the flaw. I am just writing this to help people who stumble upon this in the future.
I had a content view inside the ScrollView that had a problematic constraint. I set it to have "Equal Heights" with the ScrollView but upon loading the screen the height was static. Only half of the scroll view showed and that half would be registered as the height for the UIView. Since it was static the view would not become larger when I'd scroll, and the 4th collection view would not be inside that container view anymore. For some reason, since the collection view wasn't in the container view it wouldn't register touches.
Solved by manually making the height the same value of the scroll view! This allowed the content view to contain all of the collection views which made them behave normally again.
Just take NSLayoutConstraint of height of the UIView inside the UIScrollView
#IBOutlet weak var scrollContentViewHeight: NSLayoutConstraint!
Set height of this scrollContentViewHeight equal to height of dynamic size of the UIScrollView
if scrollableView.contentSize.height = 840.0
then
scrollContentViewHeight.constant = 840.0
set it on viewDidLayoutSubviews
override func viewDidLayoutSubviews() {
scrollableView.contentSize.height = 840.0
scrollContentViewHeight.constant = 840.0
}

Swift: Did Tumblr add a UICollectionView in a UIScrollView?

I've been trying to replicate this effect for a couple days which was inspired by Tumblr.
I've previously asked questions on here with different approaches of the same problem but to no avail. I'm just curious as to how the engineers at Tumblr created a horizontal collection view, with two vertical collection views, and is able to scroll down without affecting the view above (without resetting the position of the view when you scroll vertically in a different tab).
Header Views
I tried this, but the header view was isolated and I had to scroll to the right to see the collectionView cells. This did not work.
Changing the topLayoutConstraint constant of my UIView (not cv header) with respect to the contentOffSet of the vertical collectionView.
This almost got the effect I wanted, except that when I scrolled horizontally, there was a huge gap between my collection view and if I scrolled in that new tab, the UIView would appear again because, again, topLayoutConstraint gets scrolled up depending on the contentOffSet of my vertical collectionView contentOffset.
Changing the position of the UICollectionView frame, and scrolling the super view up simultaneously with NSNotificationCenter.
Alas, this method did the same as method #2, except that the vertical collection view cells scrolled faster than the super view.
I ran out of options to make this work so I will show you in detail what's attempted to be replicated (also note the scroll bar on the right):
Note when I scroll down the first tab. I switch, and then scroll down further. Originally, as I've said, there would be a gap between the second main CV, and when I scrolled, the view would reposition as if were scrolling up again. On here, the view on top keeps going up. So I'm curious as to what method Tumblr engineers used to do this. UICollectionView inside UIScrollView? Other suggestions?
I believe there is no UICollectionView involved. It looks like UIPageViewController and each its page is a UITableView.
Perhaps the UIPageViewController sits in a UITableView as well - the header also moves up when you scroll. This main table has only one cell (and a header) which is occupied by the UIPageViewController.
Hope it helps.

iOS UIScrollView with UIWebView and UITableView in Storyboard

I have a complex design to create. I want to have something like this
- UIScrollView
--UILabel
--UILabel
--UIWebView
--UITableView
--UITextField
--UIButton
I am using a Storyboard and I want the ScrollView to take the height of the Full Webview and the TableView so that there is only one parent scrolling and other scrolls are disabled and the whole page seems like one single view.
Right now, the whole UI looks very messed up and only the Webview and table view scroll indivisually and the parent scrollview not scrolling at all making the labels and textfields have a constant place and the button not showing at all.
EDIT
Using raki's solution, I used a TableViewController. I have something like below:
But the webView does not cover its full content and just shows in the area shown in the image.
How can I solve this issue?

UICollectionView inside UITableViewCell scroll behaviour

I'm trying to implement something similar to iTunes Store UI.
As you can see from the picture, there are two directions of scrolling possible. But I would like to prioritise scrolling of UICollectionView which is to the left or right because currently scroll down and scroll left/right are conflicting and causing weird behaviour.
Way to duplicate:
Scroll Down UITableView and then quickly try to swipe right or left on UICollectionView. UITableView will continue to scroll.
How can I do so? Do I need to use GestureRecognizer?
I always avoid collection view as it provides less flexibility to work with auto layout compared to a table view, however not against collection view every time. You should try the adding collection view inside a table view
There is a number of tutorials available for the same. eg (ios 8 Swift - TableView with embedded CollectionView)

Two UIViews & one UICollectionView inside UIScrollView (or better approach)

I need to have iOS app with screen like this:
screen
The idea is when user start to scroll down the first UIView to move up until the second UIView reach the top where it will stick and only UICollectionView will continue to move up.
Currently I'm using this structure
UIScrollView (main scroll)
UIView (some banners)
UIView (UISegmentedControl)
UICollectionView (grid with items, scroll is disabled, main scroll is used)
I manage to do it, but I needed to set UICollectionView height constraint manually in the code (calculated based on all items in grid) in order to appear in UIScrollView (everything else is handled by AutoLayout in Storyboard). The problem with this is that UICollectionView think all cells are visible and load them, so the whole recycling & reusing thing does not work. It's even worst because I use willDisplayCell method on UICollectionView to load more data when last cell is displayed, but now it load all pages at once.
My question (actually they are 2)
How can I fix the issue above?
What is the right way to achieve this functionality? Maybe my whole approach is conceptually wrong?
Collection view is a scroll view itself. So maybe you could have same functionality only with Collection view with sections or even custom layout?

Resources