Horizontal Stack View New Row - Swift

Stack Views's in iOS are a beautiful thing but I have realized there is no native way to create new rows in horizontal stack views. Let's say I dynamically added subviews in a horiztonal stack view and would want to create a new row once I reach an increment of 3 subviews respectively.

Would I be required to create a vertical stack view then programmatically populate it with individual horizontal stack views at an interval of 3 increments?

If so, would swift support dynamic variable creation of horzStackView1, horzStackView2, ... ?

I'm starting to believe there is an easier way to implement this but I can't think of anything as I'm new to Swift 2.

Answers


Yes, you would have to manually setup the the vertical and horizontal stack views yourself.

You may want to look into using UICollectionView it supports having cells automatically wrap onto the next row if there is not enough space.


Need Your Help

Server requests in Angular Directive?

angularjs angularjs-directive

I am going to write a Angular Custom Directive

Where does the business logic go in WCF Data service using entity framework?

wcf entity-framework entity-framework-4 wcf-data-services odata

I was looking at how you can create a WCF data service around an entity framework context and you can consume it as an EF context as well.