0

footerview次のように、各セクションにプログラムで追加しました。を見ることができましたfooterview

ただし、テーブルビューの下部または上部で上下にスクロールするとfooterviewtableviewcells.

どうすれば無効にできますか?

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if(adminOrderElements[section].expanded && [adminOrderElements[section].notes length]>0)
    {
        return 60;
    } else {
        return 0;
    }

    return 60;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footer = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 60)];
    footer.backgroundColor = [UIColor clearColor];

    UILabel *lbl = [[UILabel alloc]initWithFrame:footer.frame];
    lbl.backgroundColor = [UIColor clearColor];
    lbl.text = @"Your Text";
    lbl.textAlignment = NSTextAlignmentCenter;
    [footer addSubview:lbl];

    return footer;
}

スクロール前

ここに画像の説明を入力

スクロール後

ここに画像の説明を入力

4

1 に答える 1

2

あなたの質問を正しく理解できれば、 を に変更するだけで済みUITableViewStyleますUITableViewStyleGroupedドキュメントによると、グループ化されたスタイルを使用するテーブル ビューの場合、セクション ヘッダーとフッターはフローティングしません

于 2017-08-01T07:19:22.060 に答える