0

私のiPhoneアプリケーションには、テーブルビューがあります。

- (NSInteger)tableView:(UITableView *)tableView_ numberOfRowsInSection:(NSInteger)section
{
   return 2;
}

しかし- (UITableViewCell *)tableView:(UITableView *)tableView_ cellForRowAtIndexPath:(NSIndexPath *)indexPath;、ios 7 では 1 回しか呼び出しません。この問題を解決するにはどうすればよいですか?

    tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 158) style:UITableViewStylePlain];
    [self.view addSubview:tableView];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.scrollEnabled = NO;
    [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

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

}

-(CGFloat)tableView:(UITableView *)tableView_ heightForRowAtIndexPath:(NSIndexPath *)indexPath{
   switch (indexPath.row) 
   {
        case 0: return 98;       
        default: return 60;
    }
}
4

2 に答える 2

1

問題は、次の 1 つ (または複数) である可能性があります。

  1. データソースとデリゲートが正しく設定されていません (ここではそうではありません)

  2. numberOfRowsInSection:1を返します(ここではそうではありません)

  3. テーブル ビューでは、画面に 1 つのセルのみが表示されます (テーブル ビューのフレームは、セルの高さ + ヘッダー/フッターの高さより小さいか同じです)。

念のため、これらすべてを再確認して、結果をお知らせください。

于 2013-10-31T10:51:21.807 に答える
0

deletageANDを設定したことを確認しますdatasource

tableView.delegate = self;
tableView.datasource = self;
于 2013-10-31T10:36:09.223 に答える