UIScrollView を自動サイズ変更して、ランドスケープ モードで正しく表示しようとしています。ポートレートモードは正常に動作します。これが私のコードです:
- (void)viewDidLoad {
[super viewDidLoad];
//=== load all the custom view
NSMutableArray *controllers = [[NSMutableArray alloc] init];
int page = 0;
[controllers addObject:[self loadScrollView:[[Page1ViewController alloc] initWithNibName:@"Page1ViewController" bundle:nil] withPage:page++]];
[controllers addObject:[self loadScrollView:[[Page2ViewController alloc] initWithNibName:@"Page2ViewController" bundle:nil] withPage:page++]];
[controllers addObject:[self loadScrollView:[[Page3ViewController alloc] initWithNibName:@"Page3ViewController" bundle:nil] withPage:page++]];
self.viewControllers = controllers;
[controllers release];
//=== automaticaly define number of pages
_numberOfPages = [self.viewControllers count];
// a page is the width of the scroll view
scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
scrollView.pagingEnabled = YES;
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * _numberOfPages, scrollView.frame.size.height);
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.scrollsToTop = NO;
scrollView.delegate = self;
// First, set the number of pages
pageControl.numberOfPages = _numberOfPages;
pageControl.currentPage = 0;
}
次に、各ビュー コントローラーの nib ファイルを調べて、背景を別の色に設定し、動作するかどうかをテストしました。残念ながら、ランドスケープ モードの場合、幅と高さはポートレート モードと同じままです。
この問題を解決する方法がわかりません。誰でも私を助けてくれることを願っています。よろしくお願いします。