UICollectionView inside UITableViewCell scroll behaviour - ios

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)

Related

Is there a way to change scrollview focus programatically?

In Swift, is there a way to change scrollview focus programatically? For example, in one of my scrollviews when a user is scrolling, after the scroll has gone past a certain distance I want the scroll to stop scrolling and to immediately scroll a tableview instead. I want this to all happen in the same motion/swipe, so I need to automatically shift the focus from the scrollview to the tableview using code. Is this possible?
Using Rikh's comment, I was able to solve this using a UITableView with multiple sections and custom UITableView headers. I can use the viewForHeaderInSection method to create a custom floating header which is exactly what I need and it scrolls much more smoothly.

Scroll horizontally in UITableView - Swift 3, iOS

I need to horizontally scroll through a list of thumbnails at the bottom of the screen that shows all the user's recently taken photos / videos.
I created a UIScrollView with a UITableview inside of it.
Is this the correct approach because I can't seem to find an override method in its superclass for scrolling direction?
Most of the topics I can find online deals with putting a UIscrollview inside a TableCell, which will not work for my specific application?
The hierarchy is:
View > Scroll View > Table View > Table Cel > Content > PhotoThumbnail
Below is a screenshot of what I'm trying to do:
I am not really sure why do you want to use UITableView for horizontal scrolling which lay out there cells in vertical manner. If you want horizontal scrolling I would recommend using UICollectionView where cells can be added horizontally or vertically or both.
Still if you want tableview to be scrollable in horizontal direction I would suggest you to check this project to get inspiration or using it.
https://github.com/alekseyn/EasyTableView
Instead of using UITableView you can use UICollectionView to achieve the desired result i.e, horizontally scrollable cells with imageView and other elements that you need.

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?

UIScrollView behavior is different in iOS8

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.

Imitate the combined horizontal and vertical scrolling in the iOS iTunes store

I'm trying to create a screen similar to that in the new iTunes store:
That is, a grid that's scrollable both horizontally and vertically.
The first approach I've tried involved creating a UITableView (for the vertical rows) and, within each UITableViewCell of that UITableView, another UITableView that's rotated 90 degrees.
This seems to work visually but I'm not able to scroll vertically. I believe the gesture recognizers from the subview tables are preventing the gesture recognizers from the parent table view from receiving touch events.
Basically, the rows scroll horizontally but not vertically.
The next approach I've thought then is to create UISrollViews for each row but I was wondering if there's something I've missed?
Has anyone else encountered this issue in the past?
I have done something similar to what you have with table view inside a table view, I made the rotated 90° table view the parent instead. I think I also had to turn off scrolling for one table views when scrolling is detected in the other table view, and visa-versa.
If your trying to target below iOS 6.0, ruling out using the UICollectionView, I would try using GMGridView:
https://github.com/gmoledina/GMGridView
It's very complete and has many features. It also has horizontal paging support which may achieve what you are looking for.
You should have a look at UICollectionView.
Never tried to build something like that but... Idea :
One tableview, n-cell, each cell embed a scrollView wich can contains, n-subviews.

Resources