tableView + height of subView changes suddenly [closed]

有些话、适合烂在心里 提交于 2019-12-13 22:37:37

问题


Here is my code:

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);

Here is the log in console:

(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: 

So, after the line

self.tableHeaderView = ivHeaderContainer

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.

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

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.


回答1:


I declared the future tableViewHeader with this

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

Instead of

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

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

Next question. Why?



来源:https://stackoverflow.com/questions/21325243/tableview-height-of-subview-changes-suddenly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!