0
我有幾個UIViews作爲子視圖添加到我的主視圖控制器。在縱向模式下,我對視圖進行佈局的方式看起來很好,但是,當它向橫向模式傾斜時,子視圖的底部會被切斷。我想如果我設置框架的高度,它會允許屏幕滾動,從而揭示被切斷的子視圖的部分 - 但事實並非如此。在景觀模式下切斷UIView
- (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'? – 2011-05-27 03:15:45