2014-01-24 30 views
-2

这里是我的代码:的tableView +高度突然变化

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来自哪里。

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

函数PO1(打印对象1)只是简单地打印出来的东西。

这只发生在表被分组时。但其他分组表没有这个问题。

+1

PO1功能到底在做什么?甚至用这种方法名称猜测的零机会...... – occulus

+0

它只是打印这些东西。 –

+0

没错,外卖就是在你的帖子中用一个简单的评论来解释。 – occulus

回答

0

我宣布未来tableViewHeader这个

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

而不是

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

问题是奇迹般地解决了。它遵循这里的解决方案:Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

下一个问题。为什么?

+0

在Stackoverflow问题的答案中没有“下一个问题”。也许编辑你的原始问题? – occulus

+0

我在说这个答案会导致另一个自然的问题。 –