I’ve seen custom subviews implemented as an UIViewController subclass, but that maybe could have been implemented as an UIView subclass.
When should I subclass UIViewController instead of UIView for a subview? Are there any drawbacks to subclassing UIViewController?
Personally, when I need some significant logic to go on, I do it with a
UIViewControllersubclass. Also, if I am looking for some of the behavior that you get fromUIViewControllere.g. presenting it modally or in a navigation controller.If you are doing something fairly simple or lightweight, a
UIViewsubclass is usually enough. I seem to have used them most often when making custom buttons and table view cells.In my experience I have found myself using more
UIViewControllersubclasses thanUIViewsubclasses, but this might not be the best, it just so happens that I feel a bit more comfortable using view controllers rather than straight-up views.