背景:アプリには家に帰る機能があります。ホームビューポートレートのみをサポートします。通常より少し強く振ると、現在のビューが回転し始めますが(これは問題ありません)、その後、揺れを検出して、ホームビューに対してpopViewControlllerを実行します。これを行うと、ナビゲーションコントローラーが正常に読み込まれますが、(ホームコンテンツ)の下のビューがバーの後ろに読み込まれ、引き伸ばされます(基本的に、ナビゲーションバーの下に読み込まれるため、引き伸ばされます)
戻るボタンは、これを横向きから縦向きにうまく処理します(トランジションの途中ではないため)
ナビゲーションバーの下にビューをロードせずにルートビューコントローラーに戻ることができるように、(シェイクからの)この方向の変更をどのように処理する必要がありますか?
編集:何が起こっているのかというと、コンテンツはそれがロードするビュー全体を持っていると考えているので、その上にナビゲーションバーがあることに気付かずに、画面全体を占めるようにそれ自体を伸ばします。読み込んでいる画像が引き伸ばされているのでわかります
50の賞金を追加しました。
編集これが私がシェイクとポッピングを検出する方法です
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
UINavigationController *navController = self.navigationController;
[[self retain] autorelease];
HomeViewController *home = [[HomeViewController alloc]init];
[navController popViewControllerAnimated:YES];
home.title =@"Home View Controller";
[home release];
}
if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
[super motionEnded:motion withEvent:event];
}
これが私のアプリデリゲートです:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
navController = [[UINavigationController alloc]init];
[self.window addSubview:navController.view];
HomeViewController *home = [[HomeViewController alloc]init];
[[self home] setFrame:[[UIScreen mainScreen] applicationFrame]];
ここにモックアップを含めます。
通常のビュー:
シェイク/ポップ後のストレッチビュー:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}