Customize UITableView

How can I use more than one UITableView in one ViewController? Is it possible to use more than one TableView per page?

In fact, I create an application form, there I have to use objects that are alternative for the combo box.

Instead, I select a TableView for the combo field.

Is this the correct method?

+4
source share
5 answers

Yes, there can be several table views in a UIViewcontroller. You need to set a tag for each type of table, and in relation to them you can load data in the form of a table.

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(tableview.tag == 1) { } else if (tableview.tag == 2) { } } 
0
source

Specifically, Goku, you can use multiple UITableViews in one UIViewController .
You just need to set both UITableView parameters to UITableViewDelegete .
For instance:

 - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView == yourFirstTableView) { // <do whatever on first table view>... } else if (tableView == yourSecondTableView) { // <do whatever on second table view>... } } 

Just make sure you set both delegates for both tables:

 yourFirstTableView.delegate = self; yourSecondTableView.delegate = self; 

See this example in case of doubt.

+2
source

Yes, you can use more than one UITableView's in one ViewController . And you can create the application form using various sections and use various types of accessories.

0
source

You can use multiple table views in one controller, just specify a different delegate for each instance of the UITableView. You can define new classes specifically to act as table view delegates, and let your controller instantiate them and define each property of the UITableView delegate accordingly.

0
source

Yes. Of course, you can use multiple table views in one controller. Just create a table in xib or manually.

And in Tableview methods you can write like this

 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if(tableview==table1){ }else if (tableview ==table2){ } } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(tableview==table1){ }else if (tableview ==table2){ } } 
0
source

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


All Articles