【问题标题】:Redraw scrollView and its contents for landscape orientation为横向重绘滚动视图及其内容
【发布时间】:2011-05-25 21:02:16
【问题描述】:

我有一个简单的页面,顶部有导航栏,底部有标签栏,中间有一个滚动视图。滚动视图包含一个标签和图像以及一个不可滚动的文本视图,该文本视图动态填充文本并适当调整大小。我一直在尝试通过以下方式使其在横向上工作:

-(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);

    }

}

这让我非常接近,因为导航栏和滚动视图正确调整大小并且滚动良好,但滚动视图中的内容偏向左侧。如何重绘内容以在滚动视图中正确排列?

【问题讨论】:

  • 你试过设置自动调整掩码吗?
  • 我不确定上述方法和 autoresizemask 掩码如何协同工作。我觉得当我开始用这种方法重绘东西时,面具会停止应用,但我对这一切还是很陌生。我会更改子视图或滚动视图的掩码吗?

标签: objective-c uiscrollview orientation


【解决方案1】:

尼克在他的评论中提供了正确的答案。我只需要更改滚动视图中项目的自动调整大小掩码。我做到了:

pic.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth;

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 1970-01-01
    • 1970-01-01
    • 2015-09-04
    • 2012-02-17
    • 1970-01-01
    • 2019-06-09
    相关资源
    最近更新 更多