【发布时间】: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