tableView + subView 的高度突然改变 [英] tableView + height of subView changes suddenly

查看:21
本文介绍了tableView + subView 的高度突然改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

UIView * ivHeaderContainer = [[UIView alloc]init];
UIView * ivFooterContainer = [[UIView alloc]init];
UIImageView * ivHeader = [[UIImageView alloc]init];
UIImageView * ivFooter = [[UIImageView alloc]init];

PO1(self.tableHeaderView);
PO1(ivHeaderContainer);
self.tableHeaderView = ivHeaderContainer;
PO1(self.tableHeaderView);
PO1(ivHeaderContainer);
[ivHeaderContainer addSubview:ivHeader];
PO1(self.tableHeaderView);

这是控制台的登录:

(41)> ivHeaderContainer: <UIView: 0x1a497700; frame = (0 0; 0 0); layer = <CALayer: 0x1a497760>>
2014-01-24 12:15:11.441 domainname[13727:40ab] <0x1a490220 Image+imageFile.m:(30)> [NSString stringWithString: self.fullFileName]: /private/var/mobile/Applications/BF1CCA03-2406-4FC9-BE33-298AD6DBAC2C/tmp/http%3A%2F%2Fimg.agoda.net%2Fhotelimages%2F475%2F4755%2F4755_08091300010092992_std.jpg.png
2014-01-24 12:37:32.767 [13727:60b] <0x165ff400 BGTableViewWithBackgroundAndTopAndBottom.m:(43)> self.tableHeaderView: <UIView: 0x1a497700; frame = (0 35; 320 0); layer = <CALayer: 

所以,在该行之后

self.tableHeaderView = ivHeaderContainer

ivHeaderContainter 的值突然变成了 [0, 35, 320, 0] 而不是 [0, 0, 0, 0].不知道35这个数字是从哪里来的.

the value of ivHeaderContainter is suddenly [0, 35, 320, 0] instead of [0, 0, 0, 0]. Don't know where the number 35 comes from.

只发生在一个 xib 上.可能是什么原因?

Only happens on one xib. What could be the reason ?

函数 PO1(打印对象 1)只是将内容打印出来.

Function PO1 (print object 1) simply print the stuff out.

这仅在表格分组时发生.但是其他分组表没有这个问题.

This only happens when the table is grouped. But other grouped table doesn't have this issue.

推荐答案

我用这个声明了未来的 tableViewHeader

I declared the future tableViewHeader with this

UIView * ivHeaderContainer = [[UIView alloc]initWithFrame:CGRectMake(0,0,.01,.01)];

代替

UIView * ivHeaderContainer = [[UIView alloc]init];

问题神奇地解决了.它遵循这里的解决方案:为什么在我的 UITableView 顶部有额外的填充,在 iOS7 中使用 UITableViewStyleGrouped 样式

Problem is magically solved. It follows solutions here: Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

下一个问题.为什么?

这篇关于tableView + subView 的高度突然改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆