标签: tablefooterview

tableFooterView 没有在表格底部正确对齐

我遇到了一个奇怪的行为UITableView。我已经设置了UIViewController一个UITableView. UITableView包含一个tableHeaderViewtableFooterView一个节页脚视图,以及几个UITableViewCell具有动态高度的s。

问题是tableFooterView出现在表格中间的某处(悬停在单元格上),而不是在表格内容的底部对齐。显然,表的contentSize属性也返回不正确的内容大小(特别是高度)。

The custom section footer view, however, is appearing in the right place (and below the actual tableFooterView -- which is hovering in the middle of the table).

Any ideas what's going on?

Note: My custom table-view (with dynamic height handing using Auto Layouts) is showing a "Ambiguous Layout: 2 views are vertically ambiguous." warning, but it's resizing correctly at run-time. …

uitableview ios autolayout tablefooterview

5
推荐指数
1
解决办法
3829
查看次数

UITableView tableFooterView显示在UITableView的顶部-错误

我创建了一个非常简单的测试用例来重现此问题。

我试图以编程方式将页脚视图设置为tableview。请注意,我指的是表视图最底部的页脚-而不是节的页脚(大多数堆栈溢出答案都使它们困惑)。

这是我非常简单的代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    UIView *footerContainer = [[UIView alloc] initWithFrame:CGRectZero];
    footerContainer.backgroundColor=[UIColor greenColor];
    footerContainer.translatesAutoresizingMaskIntoConstraints=NO;
    [footerContainer addConstraints:@[[NSLayoutConstraint
                                       constraintWithItem:footerContainer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual
                                       toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:100
                                       ],
                                      [NSLayoutConstraint
                                       constraintWithItem:footerContainer attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual
                                       toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:[UIScreen mainScreen].bounds.size.width
                                       ]]];

    self.mytableview.tableFooterView=footerContainer;
    [self.view setNeedsLayout];
    [self.view layoutIfNeeded];
}

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.textLabel.text=[NSString stringWithFormat:@"%ld",indexPath.row];
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

但是,结果看起来像这样:

在此处输入图片说明

您会注意到,页脚显示在表格视图的顶部。这是错误还是我错过了什么?

如果我将tableFooterView更改为tableHeaderView,则工作正常。因此,我也希望同样适用于页脚,但事实并非如此。

objective-c uitableview ios autolayout tablefooterview

5
推荐指数
3
解决办法
4792
查看次数

普通 uitableview 中的部分标题视图故障

我有一个UITableView带有两个部分和动态行数的普通表格视图。我还UIView为节标题返回 a 。

一切正常,除非桌子重新加载。节标题位置移动到随机位置,直到视图开始滚动。

标题视图和超级视图中的自动布局似乎没有违反。我已经设置了表格页脚视图nil或显示分页动画。并且表格视图在滚动视图中。

任何建议或解决方案为什么会出现节标题出现此故障。而这个故障只发生在 iOS 9

uitableview sectionheader ios tablefooterview ios9

3
推荐指数
1
解决办法
1173
查看次数

如何在表格中显示自定义页脚视图?

我创建了一个UIviewXib来在我的表格的页脚视图中显示它。页脚视图

import UIKit

/// This class is to display footer view in a settings table view
class FooterView: UIView {
    override func awakeFromNib() {
        super.awakeFromNib()
    }
}
Run Code Online (Sandbox Code Playgroud)

我将其显示如下:

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let view = FooterView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 140))
    return view
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return 100
}
Run Code Online (Sandbox Code Playgroud)

这有什么问题?我无法看到页脚视图并tableview在行之间获得如此多的空间。

在此处输入图片说明

uitableview ios tablefooterview swift

2
推荐指数
1
解决办法
6542
查看次数