iOS program to use multiple UITableView in a single UIViewController

后端 未结 5 587
庸人自扰
庸人自扰 2021-01-15 09:55

I am trying to implement 3 tables in a single segue in a storyboard. When one table is selected it will unhidden a view with another table and likewise one more. The followi

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-15 10:06

    You should declare your tableViews in .h file.

    @property (weak, nonatomic) UITableView *firstTableView;
    @property (weak, nonatomic) UITableView *secondTableView;
    @property (weak, nonatomic) UITableView *thirdTableView;
    

    And then all the delegate methods have variable with pointing witch object call this method, so you can check:

    -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        if(tableView == self.firstTableView)
           return  3;
       else if(tableView == self.secondTableView)
           return 4;
       else if(tableView == self.thirdTableView)
          return 100;
    }
    

    The other delegate methods work in the same way.

提交回复
热议问题