0

1 つのセクションに15 行ある 1 つのテーブル ビューがありました。したがって、テーブル ビューが読み込まれると、最初の 9 行のみが表示されます。CellForRowAtIndexpath メソッドで確認しましたが、15 行すべてをビューロード メソッドのこのメソッドで呼び出すようにしたいと考えています。私を助けてください。

前もって感謝します....

4

2 に答える 2

1

これらのメソッドを使用するか、最初のビューの前にすべてのセルが必要な場合は、最後のメソッドを使用してセルの高さを減らす必要があります。また、配列の値の量も確認してください。

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{
return 1;
}

-(NSInteger)tableView:(UITableView *)tableView  numberOfRowsInSection:(NSInteger)section 
{
return [Array count];

}
-(UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
   static NSString *CellIdentifier = @"Cell";
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   if (cell == nil) {
    cell = [[[UITableViewCell alloc]
             initWithStyle:UITableViewCellStyleSubtitle
             reuseIdentifier:CellIdentifier]
            autorelease];
 }
   cell.textLabel.text=[Array objectAtIndex:indexPath.row];


    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 20;//use this method for cell height
}
于 2012-05-07T11:25:39.583 に答える
1

設定した行数によって異なります

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

配列がある場合 [arr count];は行数として返され、静的行が必要な場合return 15;はこのメソッドで使用します

于 2012-05-07T10:53:14.420 に答える