2014-01-24 31 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

我在說這個答案會導致另一個自然的問題。 –