iPadモーダルビューの却下は、uisplitviewパネルを台無しにします

StackOverflow https://stackoverflow.com/questions/3596628

  •  02-10-2019
  •  | 
  •  

質問

前提は非常に簡単です。UisplitViewControllerを使用するiPadアプリにモーダルビューを表示したいと思います。

ビュー階層は簡単です:

                                              /- TableViewController1
                     /- root:TabBarController -- TableViewController2
SplitViewController -
                     \- detail:CustomViewController

TableViewController1のテーブルセルの1つをクリックすると、モーダルビューを開きます。

- (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)ip {
  UIViewController *vc = [[MyModalClass alloc] init];
  UINavigationController *nc = [[UINavigationController alloc]
                                initWithRootViewController:vc];
  nc.modalPresentationStyle = UIModalPresentationFormSheet;
  nc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  [self presentModalViewController:nc animated:true];
  [nc release];
  [vc release];
}

これはうまく機能します:ビューが表示されます。問題は、風景以外の方向でそれを却下しようとすると始まります。

ModalViewControllerでは、次の方法は、ナビゲーションバーのuitabbarbuttonによってトリガーされます。

- (void) closeButtonInNavBarWasClicked:(id)sender {
  [self dismissModalViewControllerAnimated:true];
}

そして、これが問題の始まりです。

このコードが呼び出されると、モーダルビューが消えますが、:TabbarController(スプリットビューのルートビュー)が突然回転してサイズ変更されます。コンテンツは突然横向きになり、詳細ビューを部分的にカバーします。詳細ビューは、サイズが小さくなるようにサイズ変更されておらず、ルートビューで部分的にカバーされています。

この問題が表示されない唯一の状況は、アプリがポートレートモードであるときにTableViewController1セルをタップするときです。ルートビューはポップオーバー(バグの十分なソースである可能性がある)にありますが、すべてが正常に機能します。

成功せずに、私がすでに試したことがあります:

  • タブバーをダンプし、スプリットビューのルートコントローラーとしてtableviewcontroller1を表示するだけです
  • Parent TableViewController1がMyModalClassビュー自体ではなくモーダルビューを却下するように、代表団のプロトコルを作成します。
  • TableViewController1.splitViewControllerでモーダルビューを提示/却下することで、実際には事態が悪化します。ビューは表示されません。
  • いくつかのヤギを犠牲にすることも役に立ちませんでした。

この問題に関する意見を大いに感謝します。

役に立ちましたか?

解決

私は自分の質問にある種の質問をしています。私は、アプリのすべてのメモリリークを体系的に排除するために楽器を使用しました。私がそれをした後、問題は消えました。

他のヒント

私はあなたと同じ問題を抱えていました。私はプログラム的に一時的にプレゼンテーションビューコントローラーを強制的に強制的に強制的に解決しました(一度戻った後)。もちろんアニメーションなし。そして、それを必要な方向に戻しました(回転前に保存しました)。

したがって、VC1がvc2をモダンに表示し、ユーザーがVC2を回転させる場合、次の呼び出しによりVC2の現在の方向に従ってVC1の方向を設定します。 // VC2の現在の方向を保存(モーダルビュー)[VC1 WillRotatetointerfaceorientation:currentorientation duration:0];

それから私はVC2を解散し、VC1を眺めながら私はこれを行います:

- (void)viewdidappear :( bool)animated {

[super viewDidAppear:animated];

/* Store wanted orientation */
UIInterfaceOrientation currentOrientation = self.interfaceOrientation; 

/* rotate to some arbitrary orientation, this solves the bug. */
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortraitUpsideDown animated:NO]; 

[[UIDevice currentDevice] setOrientation:currentOrientation animated:NO]; //restore wanted orientation.

}

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top