Chapter 5. Table, Collection, and Stack Views

In the previous chapter, we looked at Interface Builder and how it allows us to visually create our layouts using drag and drop connections.

In this chapter, we'll see how to use a combination of Interface Builder and code to create more complicated layouts using:

  • Static table views
  • Dynamic table views
  • Collection views
  • Stack views

Plain views versus Table, Collection, and Stack views

In the previous chapter, we used a plain view to create out layouts. This allowed us to show off the power of IB and allowed us to see just how easy it was to create fairly complicated layouts with drag and drop tools. But what if we want to add more structure to our layout? What if we want to show 1000 different values and let the user scroll? What if want to create an input form? For these types of layouts, it's better to start with some of the more advanced view objects that are offered:

  • Table views: These are meant to show a table of data and to optionally give the user a chance to make changes. A guest list or a settings screen are good examples of table views.
  • Collection views: These are very similar to table views. They're meant to show off a collection of data. But, unlike table views, you're not limited to one vertical stack and can instead support much more complex layouts. A photo grid is a good use case for a collection view.
  • Stack views: These were introduced in Xcode 7.0 and are a great way to lay out a group of objects in a column or a row on screen. This allows you to create complicated layouts without having to create a lot of Auto Layout constraints. An input form is a good use case for a stack view.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.127.232