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

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

I am working on an application that relies heavily on objects UITableView. I can successfully use the object UITableViewControllerand display the information in the table, but I need to have several tables on the screen that link to data from several sources, and UITableViewControllerseems too limited.

I would like to place some objects UITableViewwith a storyboard, and then create custom class files that manage tables. Unfortunately, when I tried this, XCODE does not allow me to select these custom classes for table management.

Although I found some possible workarounds on the Internet, I want to understand why it is not possible to select a new class to control the table view.

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

+4
source share
4 answers

It depends on what you have done. But you really have to take a different approach:

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

, . "" (addChildViewController:), - . , .

+2
.h
{
UITableView *objlefttableview;
UITableView *objrighttableview;
}

.m
viewdidload
{

if(!objlefttableview)
        objlefttableview=[[UITableView alloc]initWithFrame:CGRectMake(0, 87, 227, 681) style:UITableViewStylePlain];
    if(!objrighttableview)
        objrighttableview=[[UITableView alloc]initWithFrame:CGRectMake(227, 87, 263, 681) style:UITableViewStylePlain];

  [objlefttableview registerNib:[UINib nibWithNibName:@"View" bundle:Nil] forCellReuseIdentifier:@"leftCell"];

 [objrighttableview registerNib:[UINib nibWithNibName:@"ViewR" bundle:Nil] forCellReuseIdentifier:@"rightCell"];

}
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

if (self->objlefttableview==tableView)
    {

}

else
{

}

}

, tableview, ,

0

, UITableViewController UITableView , UIView UITableViewController. , , , , , , .

ViewControllers.h, UITableView, ( , - ):

@interface DHViewController: UIViewController [UITableViewDataSource, UITableViewDelegate]

.m filesDidLoad , :

self.tableAnswers.delegate =self;
self.tableAnswers.dataSource = self;
self.tableQuestions.delegate   =self;
self.tableQuestions.dataSource = self;

.m:

  • (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger)

  • (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath

... .

!

FYI (, @Wain , / - ).

0

1) UITableView .

2) .

3) Outlets ( ) tableView

. , .

Greetings :)

0
source

Source: https://habr.com/ru/post/1536570/


All Articles