ビューに2つのサブビューを追加したUIPageViewControllerがあります.UITapGestureRecognizerを持つ透明なサブビューと、他のサブビューをタップすると下からスライドするいくつかのボタンを持つツールバーです。
編集。これは、viewDidAppear:(BOOL)animated のサブビュー設定です。
CGRect frame;
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])){
frame = CGRectMake(50, 0, 220, 480);
}
else {
frame = CGRectMake(50, 0, 380, 320);
}
if (!tapView) {
tapView = [[LSTapView alloc]initWithFrame:frame];
//[tapView setBackgroundColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:0.4]];
[self.view addSubview:tapView];
[tapView release];
}
else {
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])){
[tapView setFrame:CGRectMake(50, 0, 220, 480)];
[fontViewController.view setFrame:CGRectMake(0, 480, 320, 92)];
}
else {
[tapView setFrame:CGRectMake(50, 0, 380, 320)];
[fontViewController.view setFrame:CGRectMake(0, 320, 480, 92)];
}
}
if (!fontViewController){
fontViewController = [[LSFontViewController alloc]initWithNibName:@"LSFontView" bundle:nil];
}
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])){
[fontViewController.view setFrame:CGRectMake(0, 480, 320, 92)];
}
else {
[fontViewController.view setFrame:CGRectMake(0, 320, 480, 92)];
}
[self.view addSubview:fontViewController.view];
デバイスを回転させずにページを変更すると、すべてが両方の向きで正常に機能します。それにもかかわらず、デバイスを回転させると、これら 2 つのサブビューが消え、前面にないことがわかります。とにかく、これをコードに追加すると:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[self.view bringSubviewToFront:tapView];
[self.view bringSubviewToFront:fontViewController.view];
}
何か奇妙なことが起こります: ページを変更することはもうできません。または、前と次の viewController は正しく読み込まれますが、それらは表示されず、ページは変更されません。
誰かが私に何が起こっているのか説明できますか?
ありがとうございました。L.