2012-10-11 65 views
0

enter image description here如何在設備方向更改後防止UIScrollView的大小?

我在肖像模式下的xib-file上有UIScrollView。當我運行應用程序並將設備旋轉到橫向模式時,我看到UIScrollView的新界限。底部UIScrollView內部的一半控件無法訪問。沒有任何可見的滾動條。

如何防止更改設備方向後更改UIScrollView的垂直尺寸?

enter image description here enter image description here

非常感謝您的幫助!

+0

您需要爲scrollview設置contentSize。檢查是否設置正確。滾動顯示基於此。 – iDev

+0

我知道 - 但它並沒有幫助:( – Dmitry

+0

你可以請張貼一些更多的細節,例如你想要做什麼以及確切的結果是什麼?是否你在shouldAutorotateToInterfaceOrientation中設置的框架不被接受所有?或方法本身沒有被調用? – iDev

回答

0
  1. 設置基準出口
  2. 使用代碼:

    scrollView.contentSize = CGSizeMake(width,height);

0

更改UIScrollView的幀在

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; 

根據該裝置的旋轉。

0
shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    { 
     if(interfaceOrientation == UIInterfaceOrientationPortrait) 
    { 
     //set frame for scroll in portrait mode 
    } 
    else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) 
    { 
     //set frame for landscape 
    } 

    } 
0

編輯:選擇您的UIScrollView並更改自動調整大小屬性這樣的滾動視圖。

enter image description here

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; 
{ 
    //change sub view of scrollview accordingly to orientation 
    if(UIInterfaceOrientationIsPortrait(interfaceOrientation)) 
     yourScrollView.frame = CGRectMake(0,0,320,460); 
     yourScrollView.contentSize = CGSizeMake(320,460);//change accordingly 
    else 
     yourScrollView.frame = CGRectMake(0,0,480,300); 
     yourScrollView.contentSize = CGSizeMake(480,460); //change accordingly 

    return YES; 
} 
+0

謝謝。這是行不通的。我不知道爲什麼。 – Dmitry

+0

檢查編輯答案...... –

+0

不要工作太:( – Dmitry

0

選擇您的UIScrollView,然後從屬性中單擊大小檢查和更改自動調整大小屬性視圖。

see image

+0

This is doesn – Dmitry

+0

這對我來說可以嘗試不同的設置來實現自動調整屬性。 –

+0

Autoresize不會幫助:( – Dmitry

相關問題