重绘scrollView及其内容以实现横向

发布于 2024-11-09 14:19:16 字数 732 浏览 3 评论 0原文

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

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

    }

}

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

I have a simple page with a nav bar at the top, tab bar at the bottom, and a scrollview filling the space between. The scrollview contains a label and image and a non-scrollable textview that gets dynamically filled with text and sized appropriately. I've been trying to make it work in landscape by using:

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

    }

}

This gets me very close as the nav bar and scrollview resize correctly and it scrolls nicely, but the content within the scrollview is off to the left. How do I redraw the contents to line up correctly within the scrollview?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖微凉心微凉 2024-11-16 14:19:16

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

pic.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth;

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

Nick provided the correct answer in his comment. I just had to change the autoresizemasks of the items in the scrollview. I did:

pic.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth;

for each item in the viewDidLoad method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文