Custom UIView as a UITableView delegate and data source?

I am writing a rather complicated iPad app - my first major one.

There are some custom UIViews in this app that contain pretty complex data, including a table. These views do not occupy the entire screen, and at any time (and probably will) there will be many of them on the screen (although only one of them will be in the expanded state where the table is displayed).

Here is a basic example that should convey the basic principle: Made with the nice Antetype prototyping app

Please note that these things should not be in popovers; instead, FamilyViews expand to show their details. (And please also note that this layout was created just for the sake of this issue and has little to do with how my interface will look, I know that this is not a good screen design)

I have not decided who should put the delegate and data source of these user views:

  • Creating a ViewController for the current screen delegate and data source is inelegant because not only one table is part of the main VC view.
  • When creating a View , the delegate and data source seem a little strange to me because it seems that the view is too active; turning it into a semi-controller.
  • Creating the base model object The data source seems too dense and also splits the MVC. And he does not answer the question of who should be the delegate.

I strive to have each of these "FamilyViews" delegate and source data for their own tables. The action in these tables should be related to the FamilyView (ViewController) delegate, but that should not be a problem, right?

Does anyone have any input on this?

+7
source share
1 answer

Views must know how to draw themselves and compose their sub-matrices, depending on their properties and what it is.

You should definitely allow the controller class to be a delegate instead of the view itself.

However, the delegate controller does not have to be a view controller that displays the view. It can be a completely separate controller class that only knows how to handle what the view requires.

+6
source

All Articles