视图控制器中的多个tableview

时间:2015-09-10 02:18:51

标签: objective-c tableview

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

我需要TableView1来显示列表而不截断列表。现在它只显示两个项目,其余项目被Label" Directions"隐藏。

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

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

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

  1. Scroll Enabled = False
  2. Clip subviews = False
  3. 自动调整子视图= False
  4. 此外,这是我的代码,用于填充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;
    }
    

1 个答案:

答案 0 :(得分:0)

如果您希望一次显示所有数据而无需滚动表格,那么您使用UITableView的原因是什么?看看你的问题,好像,你只在表格视图中显示NSString。我建议您放弃UITableView想法,然后选择UILabel进行展示。

即使您的应用需要UITableView,您也必须在contentSize / UITableView加载UITableView时根据数组中负责填充{{1}的项目数量而加载@app.route('/get-file/<name>') @app.route('/get-file') def get_file(name=None): fs = gridfs.GridFS(MongoClient().CINEfs_example) if name is not None: f = fs.get_last_version(name) r = app.response_class(f, direct_passthrough=True, mimetype='application/octet-stream') r.headers.set('Content-Disposition', 'attachment', filename=name) return r return render_template('get_file.html', names=fs.list()) 1}}。

例如。 tableSize / table view的高度=(数组中的itmes数)*(行的高度);

相关问题