UI ScrollView隐藏在iPad横向模式中

时间:2011-10-05 14:18:14

标签: iphone ipad

我已经添加了一个UIScrollView和2个UIImageView。它在potrait模式下表现得很好。但它隐藏在横向模式中。我从xcode n模拟器运行并实现了方法 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation。

我是iPad编程的新手,并且卡住了。感谢任何帮助。

2 个答案:

答案 0 :(得分:1)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

    if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
    {
        [self.view insertSubview:scrollView aboveSubview:imageView];
    }
    else
    {

        [self.view insertSubview:imageView aboveSubview:scrollView];
    }

    return YES;
}

答案 1 :(得分:1)

问题似乎是您添加的这些视图的自动调整。如果您是从Interface Builder创建它们,请转到右侧面板上的第五个选项卡并选择一个视图,您可以设置视图以在父视图更改其大小时调整其大小和位置(旋转设备时会发生这种情况) )。如果您从代码创建这些视图,则应设置自动调整掩码(使用方法setAutoresizingMask :),您可以添加多个值以获得所需的效果。

希望这有帮助!