1

基本的にTabBarアプリであるアプリ(私の最初のアプリ)に取り組んでいます。より正確には、次のようなものがあります: - ログイン ビュー コントローラー - タブ バー コントローラー (ログインが完了したとき) - TabBar の最初のアイテムが縦向きから横向きに切り替わるときに使用される横向きビュー コントローラー。

そのため、最初のタブにいるときは、横向きビューに移動して他のデータを表示できるようにする必要があります。私のタブ バー コントローラーでは、これらのメソッドを実装しました。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if([self selectedIndex] == 0)
    return YES;

return NO;
}


- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

// Get AppDelegate
MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate];

 if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
 {
     // Remove TabBarView and add graph Landscape View   
     [self.view removeFromSuperview];
     [delegate setSubViewLandscapeViewController];
 }
}

デリゲートでは、setSubViewLandscapeViewController と setSubViewTabBarController を実装しました。

- (void)setSubViewTabBarViewController {    
[window addSubview:[tabBarController view]];
}

- (void)setSubViewGraphLandscapeViewController {
[window addSubview:[landscapeViewController view]];
}

私は、landscapeViewController をランドスケープ モードでのみ表示したいので、(自分の landscapeViewController で):

- (void)viewWillAppear:(BOOL)animated {
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

NSLog(@"willRotateToInterfaceOrientation");
}

これの一部は正常に機能します。つまり、縦向きから横向きへの切り替えは問題なく (最初のタブにいるとき)、SuperView から tabbarcontroller が削除され、代わりに横向きビューがサブビューとして追加されます。

問題は...ポートレートモードに戻す方法がわかりません(そして、デリゲートのsetSubViewTabBarViewControllerを使用して、前のコントローラーであるtabBarコントローラーをロードします)。willRotateToOrientation、willRotateFromOrientation、..デバイスを実際に横向きビューから移動すると、トリガーされないようです...

要するに、私が横向きのビューにいるとき、タブバー ビューに戻るにはどうすればよいかわかりません... このビューに入ると、横向きのビューで立ち往生しています。

ご協力ありがとうございました。

リュック

4

2 に答える 2

0

さて、私はこの問題の解決策を得ることができました。実際、ポートレートからランドスケープに移行する際に、ウィンドウのサブビューからタブバーコントローラーを削除し、代わりにランドスケープビューコントローラーを追加しました。それは正しいことではなかったようです。代わりに、landscapeViewController を tabbarcontroller のサブビューとして追加し、横から縦に移動するときにそれを削除します。私はまだ問題を抱えていますが、ランドスケープ ビューの y 位置は、連続していくつかのデシブ ローテーションを行うと変化するように見えます....よろしく、リュック

于 2010-07-05T07:32:59.913 に答える
0

サンプル フォルダーにある CPTestApp-iPhone の円グラフを見てください。-(void)didRotateFromInterfaceOrientation:回転後にグラフを実装してサイズ変更することにより、回転を処理します。

于 2010-06-30T23:42:27.773 に答える