用ios的手机打开项目的基本详情页,发现底部的tableFooterView没法往上拖动了,如图所示:
我这的tableFooterView是关联一个自动布局的view,打印了一下tableFooterView的高度居然显示为0,但是这在ios10之前是完全没问题的,网上搜了很久很久,在stackoverflow上提问可能因为格式问题还被管理人员警告并且删帖,折腾了几天终于找到一篇:http://m.2cto.com/kf/201506/411277.html
这里我就直接复制过来,如下所示:
【343】【奇怪的bug】
问题描述:
1、tableView是通过IB,并且有自动布局;
2、headView是通过代码创建的
3、给tableView加headView,没有问题
4、给tableView加footerView,当用代码创建时,也没有问题
5、但是:当footerView是用自动布局时,tableView首次展示时,footView高度为0;
但是,当jump到一个控制器,并且再次返回时,tableView再次显示,此时footView高度正常了。。。
问题原因:
猜测是:tableView的自动布局影响的
解决方法:
当前 想到的是:线程延迟几秒再给tableView设置footView
self.tableView.tableHeaderView = self.headView;
_footerView = [RowView RowView];
// 这里加个延迟,不然会高度为0,应该是自动布局导致的问题
kWeakSelf
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
kStrongSelf
strongSelf.tableView.tableFooterView = _footerView;
[UIView animateWithDuration:5 animations:^{
[strongSelf.view layoutIfNeeded];
[strongSelf.tableView layoutIfNeeded];
}];
});
用了这个解决方法,我的问题得以解决,最终效果图:
3395

被折叠的 条评论
为什么被折叠?



