Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在UIViewController中以编程方式创建多个UIableView?_Iphone_Ipad_Xcode4.3 - Fatal编程技术网

Iphone 如何在UIViewController中以编程方式创建多个UIableView?

Iphone 如何在UIViewController中以编程方式创建多个UIableView?,iphone,ipad,xcode4.3,Iphone,Ipad,Xcode4.3,我想在UIViewController中以编程方式创建2个UITableView。我有两个NSMutableArray用于数据,分别是*firstTableDatas和*secondTableDatas。我可以通过编程方式创建一个UITableView,但当它变为2时,我不知道代表的2 UITableView的返回值是什么: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)secti

我想在UIViewController中以编程方式创建2个UITableView。我有两个NSMutableArray用于数据,分别是*firstTableDatas和*secondTableDatas。我可以通过编程方式创建一个UITableView,但当它变为2时,我不知道代表的2 UITableView的返回值是什么:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
}

如何在2个单独的UITableView中加载数据

提前感谢。

使用

if(tableView ==Firsttable)
{
...
}
else
{
...
}


将diff标记赋予tableView,并在这些标记的基础上执行所需的功能

例如:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
      if(tableView.tag==1)
      {
          return 100;
      }
      else if(tableView.tag==2)
      {
           return 50;
      }
      return 40;
}

您可以通过以下方式进行检查:

if(tableView ==firstTableDatas)
{
    //Code related to First Table
}
else if(tableView ==secondTableDatas)
{
    //Code related to Second Table
}
它将在UITableViewDelegate方法中工作


愉快的编码。

在这里,您可以找到示例代码,其中详细解释了两种不同的编码方法:请参阅中的“我的答案”
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
      if(tableView.tag==1)
      {
          return 100;
      }
      else if(tableView.tag==2)
      {
           return 50;
      }
      return 40;
}
if(tableView ==firstTableDatas)
{
    //Code related to First Table
}
else if(tableView ==secondTableDatas)
{
    //Code related to Second Table
}