2011-05-25 74 views
1

我有一个简单的页面,顶部有一个导航栏,底部的标签栏和填充其间的滚动视图。滚动视图包含一个标签和图像以及一个不可滚动的textview,可以动态地填充文本并适当调整大小。我一直在尝试使用,使其在景观工作:重绘scrollView及其内容为横向

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    { 
     NSLog(@"called"); 
     navBar.frame = CGRectMake(0, 0, 480, 32); 
     sview.frame = CGRectMake(0, 32, 480, 240); 
    } 
    else { 
     navBar.frame = CGRectMake(0, 0, 320, 44); 
     sview.frame = CGRectMake(0, 44, 320, 372); 

    } 

} 

这让我非常接近的导航栏和滚动型正确调整大小和它很好地滚动,但滚动视图中的内容是关闭的左。如何在滚动视图内重新绘制内容以正确排列?

+0

你试过设置autoresizemask吗? – 2011-05-25 21:13:15

+0

我不确定上面的方法和autoresizemask mask是如何一起工作的。我觉得当我用这种方法重新绘制事物时,面具停止了应用,但我对这件事情很新颖。我会更改子视图或滚动视图的蒙版吗? – Ryan 2011-05-25 21:23:50

回答

1

尼克在他的评论中提供了正确的答案。我只需要更改scrollview中项目的autoresizemasks。我做了:

pic.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth; 

对于viewDidLoad方法中的每个项目。