How to display two tables in a user interface view

I would like to use and display two tables in a user interface view. Please let me know how to do this. Any code would also be appreciated.

Thanks Sandeep

+3
source share
1 answer
  • Add 2 UITableViews to your view in IB and connect them to two different outputs in the file owner (or just assign different tag properties).
  • Set a delegate and a data source for them (there may be one and the same view controller for both).
  • In the delegate / data source methods, you do the following:

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    
        if (tableView == myFirstTable)
            // return value for 1st table
        if (tableView == mySecondTable)
            // return value for 2nd table
         return 0;
    }
    

or if you use the tag approach:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{   
    switch(tableView.tag){
         case firstTag:
            // return value for 1st table
         case secondTag: 
            // return value for 2nd table
    }
    return 0;
} 
+16
source

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


All Articles