【问题标题】:UIView cut off in landscape modeUIView 在横向模式下被切断
【发布时间】:2011-05-27 03:00:19
【问题描述】:

我有几个 UIViews 作为子视图添加到我的主视图控制器中。我的视图布局方式在纵向模式下看起来不错,但是,当它倾斜到横向模式时,子视图的底部会被切断。我想如果我设置框架的高度,它将允许屏幕滚动,从而显示被切断的子视图的部分 - 但事实并非如此。

- (void)didRotate:(NSNotification *)notification {

    UIDeviceOrientation orientation = [[notification object] orientation];

    if (orientation == UIDeviceOrientationLandscapeLeft) {
        self.view.frame = CGRectMake(0.0, 0.0, 1024.0, maxHeight);
    } else if (orientation == UIDeviceOrientationLandscapeRight) {
        self.view.frame = CGRectMake(0.0, 0.0, 1024.0, maxHeight);
    }
}

我也尝试将 UIScrollView 添加到主视图,然后将上述子视图添加到滚动视图

- (void)viewDidLoad
{
    scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:scrollView];

    //add views to scrollView

    [super viewDidLoad];
}

如果子视图超出屏幕尺寸,如何使主视图“滚动”?

【问题讨论】:

  • 你如何定义maxHeight

标签: objective-c xcode ios


【解决方案1】:

将视图添加到滚动视图后,必须设置滚动视图的contentSize 属性,以便滚动视图知道要滚动到的内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 2012-12-20
    • 1970-01-01
    • 2012-09-14
    • 1970-01-01
    相关资源
    最近更新 更多