0

在此处输入图像描述

我有UIScrollView纵向模式的xib文件。当我运行应用程序并将设备旋转到横向模式时,我看到了UIScrollView. UIScrollView底部内部的一半控件无法访问。没有任何可见的滚动条。

如何防止更改UIScrollView设备方向后的垂直尺寸变化?

在此处输入图像描述 在此处输入图像描述

非常感谢您的帮助!

4

5 回答 5

0

更改 UIScrollView 的框架

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;

根据设备旋转。

于 2012-10-11T05:42:53.733 回答
0
 shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
      if(interfaceOrientation == UIInterfaceOrientationPortrait)
    {
         //set frame for scroll in portrait mode
    }
    else  if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    {
      //set frame for landscape
    }

   }
于 2012-10-11T05:49:22.183 回答
0

编辑:选择您的 UIScrollView 并像这样更改滚动视图的 autoresize 属性。

在此处输入图像描述

 - (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;
 }
于 2012-10-11T05:52:32.477 回答
0

选择您的 UIScrollView,然后从属性中单击大小检查器并更改视图的 autoresize 属性。

看图片

于 2012-10-11T05:58:30.583 回答
0
  1. 设置参考插座
  2. 使用代码:

    scrollView.contentSize = CGSizeMake(宽度, 高度);

于 2012-10-24T15:39:19.303 回答