2010-10-22 104 views
0

我想一個頁腳視圖添加到我的gouped表視圖 現在我有這樣的:框架寬度有奇怪的行爲

NSLog(@"width:%f",self.view.frame.size.width); 
     UILabel *lblInfo = [[UILabel alloc] initWithFrame:CGRectMake(50, 30,self.view.frame.size.width - 100, 70)]; 
     lblInfo.text = @"Hellow"; 
     [footerView addSubview:lblInfo]; 
     [lblInfo release]; 

這給了我這樣的結果:http://img256.imageshack.us/i/schermafbeelding2010102t.png/ 這是景觀和self.view是我的splitcontrol的詳細視圖的子視圖。 第一個的的NSLog: - >寬度:703

如果我轉動(肖像)它,我得到這樣的結果:HTTP://img821.imageshack.us/i/schermafbeelding2010102.png/ 的NSLog的的第二: - >寬度:768

通常兩個頁腳意見應該有一個離開的50像素&右邊緣......

我是什麼監督?

回答

1

您應該設置autoresizingMask

lblInfo.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; 

你也應該注意與頁腳的尺寸創建標籤:

UILabel *lblInfo = [[UILabel alloc] initWithFrame:CGRectMake(50, 30,footerView.frame.size.width - 100, 70)]; 
+0

這相當於你在Interface Builder做什麼,在檢查員的大小部分。 – 2010-10-22 09:05:18

+0

哇不知道:)是什麼|炭?它是否像「或」一樣?我試過了,但現在我有這樣的結果:http://yfrog.com/5oschermafbeelding2010102p(所以我還沒有) – meersmans 2010-10-22 13:51:17

+0

是_footerView_寬度_self.view_,在你的例子?當您創建標籤時,請嘗試使用_footerView.frame.size.width - 100_創建寬度。 – 2010-10-22 14:09:52