私は4つのセクションを持つテーブルビューで作業しています。セクションごとにヘッダービューを実装しました。 tableview
style
をPlain
とすると正しく動作します。私がtableview
style
をGrouped
とすると、それは有線に見えます。iOSでtableviewスタイルがグループ化されていると、セクション内のヘッダーの表示が正しく表示されない理由
これは私がtableview
デリゲートメソッドを実装する方法です。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
{
return 1;
}
else if(section == 1)
{
return 1;
}
else if (section == 2)
{
return 3;
}
else
{
return 1;
}
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, 50)];
UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 0, screenSize.width-80, 50)];
if (section == 0)
{
titlelabel.text = @"Flight Summary";
[headerView addSubview:titlelabel];
return headerView;
}
else if(section == 1)
{
titlelabel.text = @"Price Summary";
[headerView addSubview:titlelabel];
return headerView;
}
else if (section == 2)
{
titlelabel.text = @"Traveller Details";
[headerView addSubview:titlelabel];
return headerView;
}
else
{
titlelabel.text = @"Book Now";
[headerView addSubview:titlelabel];
return headerView;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"checkcell"];
return cell;
}
私がイメージにPlain
リンクとしてテーブルビュースタイルを使用する場合、これはスクリーンショットです:私はGrouped
が、これはスクリーンショットです
画像へのリンク:image with grouped stye
私はこれであなたの助けを期待し、何が起こっているか見当がつかない。
なぜこれだけで、あなたが'のtableViewを実装しました 'Grouped'のテーブルビュースタイル –
ために起こるのですか? – rmaddy
いいえ私は実装しませんでした。なぜなら私は 'Plain'スタイルを使用していて、そのメソッドを必要としなかったからです。 @rmaddy –