bakkenbaeck / iOS-handbook

Guidelines and best practices for excellent iOS apps
386 stars 51 forks source link

View configuration + Auto-layout #56

Closed elland closed 7 years ago

elland commented 8 years ago

We agreed on using auto-layout as much as possible now, but in the interest of decluttering controllers and compartmentalisation, we also think we should avoid configuring the views inside the controller as well. So as much configuration code as possible should come from the view. That means that the view would become more aware of its subviews as well. So the focus would be view composition, instead of a view controller managing everything.

3lvis commented 8 years ago

UITableViewController and UICollectionViewController for example, don't required you to make a separate subclass of UITableView or UICollectionView, in the other side, if you're using UIViewController you most likely should have a subclass for your view.

elland commented 8 years ago

On the other hand, you probably don't want to use either a UITableViewController or UICollectionViewController for this, as adding subviews to them is cumbersome and full of caveats. If you're not adding any subviews, you don't have to do anything to lay them out either.

3lvis commented 8 years ago

Oh, you mean like using UIViewController with a table view or a collection view on top.

In that case maybe we could say:

If you want to use a UITableViewController or UICollectionViewController, it's better if you use SweetTableViewController or SweetCollectionController instead, since they provide you non-optional views.

elland commented 8 years ago

But we don't have them yet. 😭 should we start this today?

3lvis commented 8 years ago

gif

Wanna take care of it?

elland commented 8 years ago

@3lvis let's rock this boat.

do it

3lvis commented 7 years ago

Added https://github.com/UseSweet/SweetUIKit 💥