2 つのセクション (上部と下部) に分割したい pageviewcontroller にビューコントローラーがネストされています。それぞれのビュー (以下のコード) にフレームを正しく割り当てていますが、最初にレンダリングしたときは正しくありません。スワイプしてからもう一度戻すと、レンダリングされた画面が正しく表示されます。何が起こっているのか分かりますか?
-(void) viewDidLoad
{
self.controller1 = [self.storyboard
instantiateViewControllerWithIdentifier: @"controller1"];
self.controller2 = [self.storyboard
instantiateViewControllerWithIdentifier:@"controller2"];
[self.view addSubview:self.controller1.view];
[self.view addSubview:self.controller2.view];
[self addChildViewController:self.controller1];
[self addChildViewController:self.controller2];
}
- (void)viewWillAppear
{
UIInterfaceOrientation orientation = self.interfaceOrientation;
BOOL navigationBarHidden = [self.navigationController isNavigationBarHidden];
CGRect navigationBarFrame = self.navigationController.navigationBar.frame;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
CGRect viewSize = self.view.frame;
self.controller1.view.frame =
CGRectMake(0, 0, screenBounds.size.width, screenBounds.size.width);
self.controller2.view.frame =
CGRectMake(0, screenBounds.size.width,
screenBounds.size.width, applicationFrame.size.height - screenBounds.size.width);
}