Is there a better way making horizontal scroll between different table views? - ios

I need to implement the following feature:
I need to show a user list of many table views containing many cells each. One table view at a time. So user scrolls up and down within current table view and scroll left and right to go between different table views.
The way that I implemented it right now:
I have a scroll view occupying full screen.
Content size for this scroll view is three times wider then size of the screen.
In this content I layout three different table views.
Only second (middle one) table is displayed initially.
When user scrolls right or left I catch the end of scrolling event and reposition content back to the middle view and reload all three table views.
Am I missing something? Is there way to optimize it?

Here is a github liker for SwipeView. Just to implement datasource to setup tableViews on. This is useful for me.

Related

How do you extend the height of a collection view and not have scrolling, but have scrolling on the outside view?

Right now, I have a collection view with scrolling inside a view.
I'd like the collection view's height to expand downward depending on how much content it has and not have any scrolling.
A user would then scroll from the outside view.
The collection view is the last section in the screenshot:
I tried using a table view with one cell having a collection view and that did not work.
"I am fairly new to Swift..."
You may want to first spend some time researching different ways to layout UI elements.
Depending on how many "repeating" elements you'll potentially have, you might want to take this approach:
If you'll potentially have many, many "repeating" views (cells), you might be better off using a collection view - with its built-in memory management - using one of these approaches:
Or, possibly a collection view with a Compositional Layout.
In any case, trying to "expand the collection view to show all the cells and then scroll the whole thing" defeats the purpose of using a collection view, and is rarely the appropriate way to go.

ioS Scroll View with dynamic table View

I want to create a “ViewController” Scene with a “Scroll View” and in this view there should be a “Table View” at the top, 1 “segmented Control and 2 tables at the bottom.
The “Segmented Control” should switch the bottom table views.
Like in this picture:
My problem with this scene is that the table should have a dynamic height.
I need the bar over the complete page and not in the individual tables.
Is it possible to create such a scene and if yes, which constraints do I have to set?
I hope you can help me! Thanks a bunch!
tableView inside scrollView is a disastrous idea, because
tableView itself have its own scrollView.
Scrolling will be very sticky and it may freeze UI.
The best solution comes on my mind is to take single tableView and manage multiple sections.
The Green portion will be your first section.
Segment control will be second.
and blue section will be third.
In this way you can achieve both dynamic height as well as single scroll bar condition.
Let me know if it works.

how to reduce spacing between multiple table views?

In this I had placed two table views on a single scroll view so that i had given constraints where as coming to landscape mode the space between the first table view and the other table view is increasing and is as shown here :
In portrait it works fine and there is not that much space can anyone help me how to reduce this ?
Bad idea using two table Views in scrollView. Use one tableView and make manipulate with items in dataSource which fill tableView, after items changed reload needed cells, and table view redraw.

How should I approach structuring this view?

I'm having a hard time finding the best way to structure this design.
The top view has a minimum height and becomes sticky when it reaches this height. The bottom view hosts a paging controller with three views within. Each of these views hosts either a collection view or table view with vertical scrolling.
I'm really at a loss on how to approach this. Is the entire view scrollable and I should prevent scrolling on the second view until the top view has reached it's sticky height? Or are each of these views separate uitableviews and the pagingcontroller is just one cell? Should I even be using a pagingcontroller or should I use a scrollview with paging enabled? (the latter was a little rough interaction-wise)
Thank you!
Take a look at the Advanced User Interfaces using Collection View from WWDC this year. This view is very very very similar to the iTunes Connect app interface. The entire session video explains how they created that interface.
I used a similar method to this to create the keyboard in the Emojicate app.
I think what I'd do is actually fake the sticky header. So something like this...
Use only one collection view.
Create a "segmented data source" that contains three data sources. (See the video from WWDC about this)
When the segmented control is changed then update the collection view by changing its layout and (if you want) dataSource.
Make the entire top section a header on the collection view.
When the collection view scrolls past a certain point (when you want to sticky the header) then have a second view that is the compressed header and make it visible at the top of the screen. This is not attached to the collection view at all.
When the segmented control changes you can update the collection view by changing the "selected datasource". The datasource can also contain a UICollectionViewLayout that will update it.
Essentially, the tableview you are talking about is just a collection view where the cell width is equal to the screen width. i.e. fake a table view.
The sticky header isn't sticky at all. Just when it starts to go off screen you can put a fake header there instead.
It will require a duplicate (ish) view and some thinking about how to structure the data but I think this will be easier and less resource hungry than having multiple collection views and page controller and stuff.
If you want me to go through it in more detail let me know but it's a complex subject. Watch the video first.
I would make this part a navigation bar. Should be relatively easy. Just have to customize the back button with a barButtonItem and do a couple of labels in the titleView.
I would make the next part a Table View.
The tableView has 2 sections. The first section doesn't have a section header and the second section doesn't have any cells but just a section header.
First and only cell in this section:
And the rest would be the second section header's view:
This gives you the stickiness that you want because the section header will remain there even if you scroll past it and since the collection has only 2 sections the controls will always remain on top.
I think the collection/table paging part is the hardest part and I don't know clearly how it can be done. But I was thinking it could perhaps be a ContainerView. Each view of the container view would be either a tableview or a collectionview. You would have to add some code to handle the movement of the containerview relative to the second section header (possibly an autolayout constraint that attaches the containerview to the buttom of the first tableview that you implemented above).
I don't think having your tables/collections in a scrollview would be a good implementation. I think I have even read in documentation that developers should stay away from that (but I might be remembering it incorrectly).
I would have:
A "header view" with three subviews:
Fixed height top and bottom views (they stay visible at any size).
A middle view that appears/disappears as the superview grows/shrinks.
A scroll view (table or collection view are subclasses) on that partially covers the header view with a top inset set enough to reveal the underlying header view (the same way pull to refresh views are revealed).
The paging buttons could be set as table/collection view section header views.
Finally track the scroll view's scroll position to keep manually adjusting the header view height.
Another way to see this solution.
Two completely separated parts, a header view and a table view.
A simple header view (blue) that adjusts its subviews as its height changes. More precisely hides its middle subview (light blue) when it shrinks.
A table view that a) partially covers the header view in Interface builder but b) has a top inset as to avoid hiding the header view in the actual device (tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);).
The two parts are only "connected" by resizing the header view height as the table view scrolls up/down.

iOS: Make embedded Tableview "automatically" so big, it doesn't need scrolling but only the parent view does

I want an embedded table view within a view. Depending on the user this table has 1-n rows. So the size varies. If I build it right now the table view has to be scrolled if n is too big. I however don't want the tableview scrollable, but I want to make it grow automatically so the user doesn't even see it's a tableview but instead the parent view surrounding the tableview should be scrollable. Or in other words, all rows of the table should be always displayed completely within the parent and depending on n the parent becomes scrollable. How can I accomplish this?

Resources