I am developing port of application from android. In my application In one of screens I present to user collection of parameters grouped by sections. Every section is presented as page of tile items in spannable grid. User can scroll betwen sections horizontally like in pager while pages are not scrolled vertically. Additionally on top of screen user has clickable tabs showing all availible sections by title. On android I achieaved this by creating nested RecyclerViews (one lvl for sections, one for tiles), combined with DiffUtil for quick content updating.
I am completly new in iOS development but I want to create something similar. After little dive into basic components it sems like UICollectionView might be the rightest joice. In my app I am trying to use MVVM approach using RxSwift and RxDataSource. The last one has support for sectioned UICollectionView and I wonder if there is any possibility to create the whole view by using single UICollectionView. Sections would scroll horizontal and every section would contain grid elements? Or maybe can I nest one RxDataSource in other. Or maybe I cant use RxDataSource for this and i should try something else. To make clear what I am talk about i include image
I would be very gratefull for any advice because I could not find anything usefull by my hand.
I would set it up as:
UICollectionView (main)
UICollectionViewCell (single cell for whole screen - horizontal scroll)
UICollectionView (inside a cell)
UICollectionViewCell(s) (vertical scroll)
You can have a cell that takes a whole screen or is a small rectangle, it's up to you
Related
I want to implement a cross layout just like Wallapop app does on its main feed.
As you can see, it's composed of two groups of cells (Featured items, Items near you). The first group is scrolled horizontally, and the second group is scrolled vertically.
The first UIKit component that came to my mind to make that kind of layout is UICollectionView, having one section for each scrolling direction. Unfortunately UICollectionView current implementation is very limited, forcing the scroll in one direction only, no matter how many sections you declare.
So I wanted to give it a shot with vanilla UIKit components and that's what I got;
The problem with my solution is that the vertical UICollectionViewController (highlighted in green) is scrolling on its own and not pushing the horizontal UICollectionViewControllers upward.
I've also thought about using a single UICollectionViewController for the vertical cells, and setting an UIStackView with horizontal UICollectionViewControllers as needed for the horizontal cells, but it's a messy solution and doesn't scale very well, I even couldn't set a title for the vertical cells section If I opt this way.
Ideally, I want each group of scrollable cells to be it's own UIViewController in order to have a clear separation of concerns and modularity.
Is there a better way to implement a layout like the one I want with vanilla UIKit components?
The easiest and the most stable solution is to use the following view hierarchy:
Use one UICollectionView(1) instance
Horizontally scrollable sections can be implemented as Screen width UICollectionViewCell containing horizontally scrollable UICollectionView
Vertically scrollable sections should be just a regular section of UICollectionView(1)
Pros
UIKit only
Nothing extraordinary is needed - just a UICollectionViewFlowLayout everywhere
Cells are the same for Horizontally scrollable cells and Vertically scrollable cells
Good scalability and separation of concerns. Independent behaviors of Horizontal and Vertical sections each of which can have multiple data sources.
Cons
Horizontally scrollable sections should have fixed height. Otherwise scrolling behavior will be harder to maintain.
Arrow on the image means Uses!
You could use following way:
A collection view with two cell in it. First cell is for featured items and the second cell is for items near you. The first cell will cover full width and height required by your design.
For scalability use a Container View which embed a CollectionViewController which will responsible for showing featured item. This embedded CollectionViewController will scroll horizontally.
Items near you are straight forward direct cell of the initial collection view controller.
So your implementation of featured horizontal collection view remain in the embedded CollectionViewController and the items for cell remains in the primary CollectionViewController which also contain a loose connection (embedding into a container view) to the featured item.
It also does not suffer from the problem like scrolling vertically the items for sale does not scroll up the featured items.
Here is a screenshot which depicts the idea
I want to replicate this sort of UX, like in the product hunt app
I want a few scroll pages inside a tableview
I tried to replicate creating a tableview with some static cell and a cell with a container view inside that is referred to a page controller, but I have a lot of problems adjusting frames
Do you have some advices or more straightforward methods to replicate this ux?
Imagur Link to the Gif of the UX
You can achieve this effect with the help of these two libraries.
For Parralax TableView header :
https://github.com/Vinodh-G/ParallaxTableViewHeader
For horizontal scroll effect:
https://www.cocoacontrols.com/controls/instagram-feed-view
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)
I'm new in iOS development. Based on my assumption, Feature page in App Store was created using a combination of UITableView and UICollectionView. But how to do that in theory and code? I know it's a bit vague, because it's quite hard to describe it, but I just need some people to help me explain it.
For this case I will try to use these naming:
1. Top section, it's a view which showing banners of apps, people can swipe it to view another banner.
2. Middle section, views which can be scrolled horizontally. (Best New Apps, Best New Games, etc).
3. Bottom section, starts from Quick Links to the bottom.
Questions:
1. The scroll indicator is starts from the root view's top guide, that's normal, but:
a. When we scroll it up, the bounciness is start from the middle section. How to do that? Is the top section and middle section is a separated view? But how can the scroll indicator is started from the root view's top guide if top and middle section is a separated view? (Separated view means that the views should have different scroll indicator unless it's actually subviews of UIScrollView).
b. When we scroll it down, there is nothing that floating. So it looks like that the whole page is a subview of a single scroll view but the bounciness is starts from the middle section. How to create that bounciness effect while only have one scroll indicator for the whole page?
2. In the middle section, there's a several collection view that has horizontal scroll direction. Is it the best way to create it like that is to use UITableView with cell that has UICollectionView inside it? It looks like it was created that way, but:
a. Is it the most efficient way to do that?
b. Because of the case in my first question is my source of confusion.
3. The bottoms section has a different separator from the middle section. The middle section has indentation while the bottom section doesn't. How can I do that if the case is it's a UITableView?
My whole question is just how to create a layout like that. If you cannot help me by providing me some sample codes that's fine, please just explain me the concept or theory of how to do that.
If the whole answer is just I have to create it using vertical/horizontal UIScrollView from scratch that's fine. I just want to make sure of that since I tried to avoid dealing with creating manual tiling.
OK, I think I finally found my own answer.
First, I need a UIScrollView to be root of the view. Then I set the contentSize to be a specific value.
The top section can be a UIPageController or a horizontal UIScrollView.
The middle section is a UITableView with scrollEnabled to NO and cells are static. The static cells (could also be dynamic cells) will contains UICollectionView. Since the scroll is disable, it will use the scroll from the parent UIScrollView. So that's why I can get the same bouncy effect in the middle section.
The bottom section is just another cell of a UITableView.
Thanks.
This might help you with implementing UICollectionViews in your UITableViewCell: http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell
To make the first cell "float" in the TableView you could make sure that cell never goes out of screen in scrollViewDidScroll
I'm trying to figure out what kind of iOS user interface element(s) I should be using to create this interface:
At the bottom of this view, there is a list of items. This list of items can be arbitrarily long. As such, and because of the standard detail disclosure indicator and so on, it makes sense that this is a tableview.
However, the items at the top are not tableview cells. The obvious answer then, is to simply place a tableview on the view, i.e. an embedded tableview. But this leads to another obvious issue, which is that this entire view should be scrollable - there will be a button for "Add Item" underneath the list of items which you will need to be able to scroll to, and the interface will be crappy if the whole view doesn't scroll.
So, I could make it so the tableview is not scrollable, and is just as tall as it needs to be to include as many items as it needs to. Then, the entire view is embedded in a scrollview, and scrolls properly. My concern with this relates to memory management, if I do this, I don't think I'll be taking advantage of the dynamic cell creation that is inherently part of a scrollable tableview, and will instead have dozens or even hundreds of cells instantiated when the view loads.
Another alternative would be to make the entire interface a tableview, with the top portions, and the bottom button, implemented as custom tableview cells that are different from the cells that show items. In the past, however, I've found that this is a pain-in-the-ass too, but perhaps it's a pain I must endure.
In general, I feel like I'm missing an obvious approach here, since this seems like it ought to be extremely simple to implement, but I'm currently at a loss. Help is appreciated!
jjv360 mentioned it correctly, this should be 1 tableview with sections and custom cells. The different look comes from nice images.
It's all a tableview with a single cell type, and 4 sections.
The cell has an optional image, a label and the optional disclosure indicator. If those don't exist, the label expands to encompass the full space.
It's very easy to do, quite standard.