Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I change the custom class of my UITableView?

Apologies if this question is a little basic but I've spent several days trying to understand the root cause of this problem without any success.

I am working on an app which relies heavily on UITableView objects. I can successfully use a UITableViewController object and display information in a table but I need to be able to have multiple tables on screen citing data from multiple sources and the UITableViewController seems to be too limited.

I would like to be able to place multiple UITableView objects with the storyboard then create custom class files which manage the tables. Unfortunately when I've tried this, XCODE doesn't let me select these custom classes to manage the tables.

Although I've found some potential workarounds online I want to understand why selecting a new class to govern a table view is not possible.

[I wanted to post images but apparently I can´t until I have a better reputation...]

like image 642
user3535074 Avatar asked Oct 20 '22 10:10

user3535074


1 Answers

It depends on exactly what you did. But, you should really take a different approach:

If you can, use a single table view with multiple sections (with headers / footers).

If you can't do that, create a separate table view controller and table view for each section of information that you want. Then, your 'main' view controller should act as the parent and add all of the other table view controllers as children (addChildViewController:) and their views as subviews. This approach will keep your code segregated and organised rather than trying to have one controller manage many disparate views.

like image 72
Wain Avatar answered Oct 23 '22 02:10

Wain