ストーリーボードの変更によりUITableViewStyleGrouped
、UITableViewStylePlain
プレーンなテーブル ビューの上端がナビゲーション バーに固定されているのに対し、ヘッダー ビューのためにグループ化されたスタイルの上部ギャップが何らかの形であることがわかりました。
しかし、写真が示すように、ギャップ「a」が「b」よりも大きいのはなぜですか? 「a」の周りに隠し要素はありますか?このギャップを管理して、バーにも引っかかるようにするにはどうすればよいですか?
ギャップ「a」と「b」のデフォルトのサイズは? 「設定」のように、「a」と「b」を等しくする方法
以下は私の試しです
以下のように設定heightForHeaderInSection:
してみましたviewForHeaderInSection:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0.0f;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView * header = [[UIView alloc] init];
header.backgroundColor = [UIColor redColor];
[self.view addSubview:header];
return header;
}
試しheightForFooterInSection:
てみてviewForFooterInSection:
、以下のように
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.0f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView * footer = [[UIView alloc] init];
footer.backgroundColor = [UIColor yellowColor];
[self.view addSubview:footer];
return footer;
}
どちらも期待どおりに機能していないように見えます。ギャップ「a」は常にそこにあり、変更されていません。
奇妙なことに、ヘッダーとフッターの高さはまだそこにあり、最小の高さに見えます。