3

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!

enter image description here

Klaas
  • 20,950
  • 10
  • 88
  • 98
Adam Storr
  • 1,428
  • 2
  • 21
  • 43
  • So it is the sticky height you are having trouble with? – 67cherries Sep 06 '14 at 19:36
  • @68cherries That is a big part... also trying to understand how and when the pagingcontroller would be scrollable vertically. – Adam Storr Sep 06 '14 at 19:38
  • Does the “paging controller” move its pages horizontally or vertically? – rob mayoff Sep 11 '14 at 01:28
  • Hey Adam! What do you mean by "becomes sticky" ??? can the user resize the top section with finger? or? when would it "not be" sticky?? – Fattie Sep 15 '14 at 12:54
  • You would almost certainly have to use **container views** to do this. ("Everything's a container view these days!") You'd never be able to keep track of the logic otherwise. My overly-long essay on them ... http://stackoverflow.com/a/23403979/294884 – Fattie Sep 15 '14 at 12:55

3 Answers3

5

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.

enter image description here

I think what I'd do is actually fake the sticky header. So something like this...

  1. Use only one collection view.
  2. Create a "segmented data source" that contains three data sources. (See the video from WWDC about this)
  3. When the segmented control is changed then update the collection view by changing its layout and (if you want) dataSource.
  4. Make the entire top section a header on the collection view.
  5. 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.

Fogmeister
  • 70,181
  • 37
  • 189
  • 274
2

navigation bar

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.

enter image description here

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:

enter image description here

And the rest would be the second section header's view:

enter image description here

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).

Arash
  • 1,181
  • 1
  • 7
  • 14
1

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.

enter image description here

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.

    1. A simple header view (blue) that adjusts its subviews as its height changes. More precisely hides its middle subview (light blue) when it shrinks.
    2. 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.

Community
  • 1
  • 1
Rivera
  • 10,182
  • 3
  • 49
  • 96
  • This sounds like an awesome idea. I am having such a tough time figuring this out though... is there an example somewhere I could look at? Even if not a sample project, maybe a more detailed tutorial? – SAHM Nov 22 '14 at 01:01