0

I am programmatically adding a dynamic number of UIButton which are labeled as hashtags to a compact view using Adaptive Layout. Is there a way for adaptive layout to automatically calculate when the width of the view is met and a new line is needed, or do I need to calculate that myself, then manually anchor the next row of buttons under the previous and so on?

My current source gives me the following image, where a second row is needed. Appreciate any direction on this.

enter image description here

Oh Danny Boy
  • 4,857
  • 8
  • 56
  • 88
  • You could try using a `UICollectionView` and the default flow layout would handle that for you – dan Jun 14 '15 at 00:28

1 Answers1

1

Auto layout cannot do this, so if you want to use individual buttons, you'll have to calculate it yourself. Another alternative would be to use a collection view which will automatically layout the buttons (cells).

rdelmar
  • 103,982
  • 12
  • 207
  • 218