Objective c 视图控制器中的多个tableview

Objective c 视图控制器中的多个tableview,objective-c,tableview,Objective C,Tableview,我在视图控制器中有两个表视图。一个表视图显示成分列表,另一个显示方向列表 我需要TableView1在不截断列表的情况下显示列表。现在它只显示了两个项目,其余的项目被标签“方向”隐藏 我希望tableview向下推标签以显示列表中的所有项目。如何在不滚动表视图的情况下一次显示所有表视图数据 第二个表视图遵循相同的故事。它显示了配方说明的列表。现在它将只显示3-4个项目。基本上与我在故事板中的大小相关。我基本上希望大小是动态的 问题在于UI。 这是我试过的 滚动启用=错误 剪辑子视图=False

我在视图控制器中有两个表视图。一个表视图显示成分列表,另一个显示方向列表

我需要TableView1在不截断列表的情况下显示列表。现在它只显示了两个项目,其余的项目被标签“方向”隐藏

我希望tableview向下推标签以显示列表中的所有项目。如何在不滚动表视图的情况下一次显示所有表视图数据

第二个表视图遵循相同的故事。它显示了配方说明的列表。现在它将只显示3-4个项目。基本上与我在故事板中的大小相关。我基本上希望大小是动态的

问题在于UI。 这是我试过的

  • 滚动启用=错误
  • 剪辑子视图=False
  • 自动调整子视图的大小=False
  • 此外,下面是我在tableview中填充列表的代码

        - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSLog(@"Method call");
        if (tableView == self.ingredientsTableView) {
            static NSString *cellIdentifier = @"Ingredients Cell";
            UITableViewCell *ingredientCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
            if (!ingredientCell) {
                ingredientCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
            }
    
            //display the ingredient
            ingredientCell.textLabel.text = [NSString stringWithFormat: @"%@", self.recipe.ingredients[ indexPath.row]];
            NSLog(@"Ingredient %@", ingredientCell.textLabel.text);
    
            //return ingredient
            return ingredientCell;
    
        } else if (tableView == self.directionsTableView) {
            static NSString *cellIdentifier = @"Directions Cell";
            UITableViewCell *directionCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
            if (!directionCell) {
                directionCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
            }
    
            //display the direction
            directionCell.textLabel.text = [NSString stringWithFormat: @"%@", self.recipe.directions[ indexPath.row]];
            NSLog(@"Directions %@", directionCell.textLabel.text);
    
            //return ingredient
            return directionCell;
    
        }
    
        return  nil;
    }
    

    如果您想一次显示所有数据而不必滚动表格,那么为什么要使用
    UITableView
    ?查看您的问题,您似乎只在表视图中显示
    NSString
    s。我建议您放下
    UITableView
    idea并选择
    UILabel
    显示

    即使你的应用程序需要
    UITableView
    ,你也必须根据数组中负责填充
    UITableView
    的项目数,在加载时给出
    UITableView
    contentSize
    高度


    例如,contentSize/表视图的高度=(数组中的ITME数)*(行的高度)

    你做了什么?请发布您的编码。您可以发布图像,以便我们了解您如何放置tableview?