Main Menu Button Grid iOS - ios

There are plenty of good grid-of-button controls out there (such as GMGridView) and tutorials around UICollectionView (here).
However, they all seem to focus on imitating the look and feel of the Springboard of Photos app.
I'm looking for something that is more like the main menu you might see in a game. Where if I had one button, I want it to fill my view and be centered. Two buttons I would expect to share the space. Five buttons would have either a button on top (or below) a box of four buttons centered.
Is this sort of dynamic sizing of buttons to fill its parent container and centered of controls into columns easily accomplished with UICollectionView or would it be better to head down the path of something custom where I have a fixed layout support for, say, 1 - 5 button configurations.

Related

Create Horizontal ScrollView

I want to know how to create a horizontal scroll view in Swift. I also want to know how to add buttons to the scroll view. An excellent example of what I'm essentially asking for is in the game "Cut the Rope."
In the picture you're presented with a picture (which you can click on) of a "fabric box." There are other different types of boxes that, with scrolling, you can access them. How would I do something similar to this?

xcode 7.3 swift What UI views make up the structure of this display?

I'm trying to figure out the structure of this iphone app display, but for the life of me I can't work out a convincing structure. I think my understanding of Nav Bars, Views, Toolbars, maybe embedded toolbars, icons, etc is just too weak to figure this layout out.
I've read endless Apple doc, and net tutorials, but none of them address things as pretty (and complex?) as this layout, simple as it looks.
I've spent hours trying to build a stack view for the top bar, with two left/right icon buttons, with an embedded toolbar (+ 3 bar button items) in the middle. But with zero success -- I posted a separate question on why my embedded toolbar with 3 buttons disappears in the stack view with distribution=Fill Proportionately.
Could anyone give me a convincing layout structure that I can try? And how about the dark blue color, with a sunken border around the 3 center buttons, and a darker background for the selected button? (Is the selected button a separate image from it's unselected state?)
And then the second collection -- is it a view with rounded corners behind the controls, or is it something else? How might I space out the left/right arrows with the long date string button in the middle (not with a horizontal stack view, I'm guessing). And the bottom buttons -- could that be a segmented control?
If you could identify the building blocks for me, that would help. Or maybe a tutorial or doc somewhere, or a code project example somewhere that I could study? (Wouldn't it be wonderful if someone had a sample app with this stuff that I could just load and learn from... :-) PS. I've also looked around the net for sample open source apps, and found probably 50, but none that I could recognize as being on target, or in swift.
Many thanks in advance.
The top area is probably a UINavigationBar, and the three things in it are its left bar button item, its title view, and its right bar button item.
The bottom part is a UITableView in Grouped style. It has two sections. The first section consists of one cell in which is laid out the whole four-subview structure. Then there's another section whose header title is "today" and each of the things after that is a cell.
The two "make a choice" rectangles, both at the top and in the first cell, are UISegmentedControls.

ios 8 layout using uitableview static cell & uitableview dynamic prototypes

I work on a app, nothing fancy, but since is my first app, there alot of stuff I never did before.
So, I'm trying to build a view like the image attached.
I've looked up on the Internet how to do something like that but I don't know what is better/cleaner way to do.
As you can see I have 3 areas: the title, the tableview in the middle and a button on the lower side.
The table will expand based on the content (3 lines or 30 lines) so the button must move down and a scroll bar should appear.
So, my idea:
Using a tableview having 3 static cells: one to put my title, second to put a tableview having prototypes cells, and a third one for the button.
That way I would have a scroll bar when the table in the middle grows, pushing the button.
Here I have a question: how to have the table view (the inner tableview) resize itself, pushing the height of the middle row, instead of having a fixed width with a scroll.
Is the the best way to achieve that?
Thanks for any idea.
C.C.
Are you sure you want to push the bottom UI down as the table grows? You say whether the table has 3 or 30 cells, but what if it has 300 cells? Your user then has to scroll to the bottom to reach the button and tab bar. I think you'll find that it would be better to use Auto Layout and let the table fill the screen space between the title and the button. The table will scroll so if you have 300 cells then you can scroll through inside the table's available area.
The advantage here is you won't be fighting with Auto Layout. If your user rotates an iPhone 4S into landscape you'll only have a few rows displayed but conversely if they run in portrait on an iPad you'll fill all of that space.
As for how to do it, the other advantage is that you don't need the nested table you describe. Use a constraint to attach the title label to the top layout guide, then attach the tab bar to the bottom layout guide. Put a vertical space constraint between the button and the tab bar. Finally, put vertical space constraints between the table and the title & the table and the button. (You'll need to implement constraints for the horizontal axis as well, but that's pretty simple.)
There's are refinements you can put into place if you want the table to shrink to fit if there are only 3 rows, but this should get you started and you may not want that anyway.
Key point: the tableView wants to scroll naturally, inside a view sized to fit the display. Don't change that behavior unless you really have to. Neither your users nor UIKit expects what you're trying to do, and the table is going to fight you all the way about it.
Nesting UIScrollViews (which your nested table would do) works, but it opens up a lot of bad UI flow problems. In my experience every time somebody wants nested scrollViews there's some other approach which is more "natural" to iOS interface paradigms.
If you're dead set on the UI you described I wouldn't use a table for the outer structure. Just make it a UIScrollView and calculate your content size based on the number of rows the table will display. You can actually do that, and then use Auto Layout as I described.

If I have different UI controls to display sequentially, should I still use a table view controller?

I want to implement something similar to this- (focus on the left portion)
I imagine possible implementations to be
Making a table view with (in this case) 7 'normal' cells, one normal size cell with a custom right accessory item, one 3XL cell containing a button, and finally a normal size cell with an imageview and custom accessory item.
or
Making a scroll view with styled view containing UILabels masquerading as 'cells', a button within a larger UIView, and another faux view-with-label-cell.
Considering the challenges posed by different screen sizes, and the want for easy configuration and modification- which way should mixed sequential data be displayed? Hacky table view, redundant scroll view, or reinvented custom UIView?
Edits
I am currently using a sliding view controller. The sliding functionality is of no worry to me, the contents of the scroll/table view within is.
There are various open source libraries available on net/github. you can use this https://github.com/edgecase/ECSlidingViewController.
Although you can make your own if you want but doing this using scrollview I don't think it will be a good way to do that.
Edit
You basically have to create 8 normal cells and change the color of the cell label which is selected. And create a footer view of YUTableview for last view.
You can use Slide-Out Navigation Panel. Use this slide-out-navigation for better understanding.
I've found more information on this, and I definitely overcomplicated a simple matter.
The answer is yes (use the table view), and there are multiple reasons- the first being the principle of always using the highest level of abstraction where practical.
StaticUITableViewCellsare completely capable of rendering other UI elements (buttons, sliders, etc) inside themselves from stock, and this is encouraged in Apple's UITableView spec. Dynamic cells, stock, are not as flexible but they can be subclassed from UITableViewCell for more custom functionality.
To speak for the example, the first X (in this case, 7) cells are likely dynamic, and the last 3 cells are static. The 'second to last' cell seems to have an infinite(?) height, and the last cell appears to be a sticky tableview footer.

UIScrollView with pagination + showing part of the previous/following pages

I'm trying to create a kind of a "game mode" menu similar to the one used by the "Cut the Rope" game to select the level pack:
What I want in particular is to achieve the same effect of showing the "current item" (in this case, the "2. Fabric Box" item) plus a bit of the previous and following items (to make sure the user is aware that there are more modes available by scrolling), with pagination enabled (to make the scroll view automatically "center" on these items).
This seems like a natural job for a UIScrollView with pagination enabled, however from the documentation it seems the pagination occurs on multiples of the view bounds.
So: if pagination occurs on multiples of the view bounds, is there any way to achieve this effect with a UIScrollView?
The fact that we see the full width of the screen would suggest that the UIScrollView frame's width would be 320px in this case, but each individual item would need to be smaller than that in order to show that little bit of the previous and next items, thus messing up the pagination...
For your reference, you can see a sample implementation of a page control from here.
https://developer.apple.com/library/content/samplecode/PageControl/Introduction/Intro.html
For the implementation you want,
to your surprise, the scrollview's width is actually smaller than 320 (or 480). The magic property to set is:
scrollView.clipsToBounds = NO
The only problem with this implementation is that the scrollview get no touch events if the touch is outside the bounds of the scrollView. This can be fix by passing its parent hitTest event to scrollView.
Just to link to to a better explanation:
UIScrollView horizontal paging like Mobile Safari tabs
Slightly different from what I recommend but does the same thing.
Edit:
I have a small project called LXPagingViews that does the above, hopefully in an out of the box manner (Do drop me a pull request or feedback in issue): https://github.com/lxcid/LXPagingViews

Resources