このトピックについては、スタックオーバーフローに関して多くの議論がありますが、私にはうまくいかない質問はありません。UISplitViewControllerが正しく回転していません
ルートビューコントローラとしてロードするSplitViewControllerがあり、SVC内の両方のテーブルビューにShouldAutoRotateがYESを返すように設定されています。
時計/ステータスバーがあっても、SVCはiPadで正しく回転しません。私AppDelegateで
更新
、私はrootViewControllerが実際に私はそれを設定するまで設定されていないことに気付きました - rootViewControllerが常に設定すべきではありませんか?
MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"RootViewController pre set: %@", appDelegate.window.rootViewController);
[appDelegate.window setRootViewController:splitViewController];
NSLog(@"RootViewController post set: %@", appDelegate.window.rootViewController);
ログ: このコード
RootViewController pre set: (null)
RootViewController post set: <UISplitViewController: 0x88ad2d0>
これは私がSVCを考えで誤解だという意味ではないが、ルートビューコントローラのですか?
また、IBでは、ウィンドウにはrootViewControllerコンセントに何も接続されていません - これは問題ですか?
SVCがプログラム行われるところです。ここで
-(IBAction)makeStory:(id)sender{
MakeSentenceTableViewController *detailViewController = [[MakeSentenceTableViewController alloc] initWithNibName:@"MakeSentenceTableViewController" bundle:nil];
UISplitViewController *splitViewController = [[[UISplitViewController alloc] init] autorelease];
UINavigationController *rootNav = [[[UINavigationController alloc] initWithRootViewController:makeStoryTableViewController]autorelease];
UINavigationController *detailNav = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
splitViewController.viewControllers = [NSArray arrayWithObjects:rootNav, detailNav, nil];
splitViewController.delegate = makeStoryTableViewController;
MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.window setRootViewController:splitViewController];
}
は両方tableviews(彼らは両方で同じです)でShouldAutoRotateセクションです:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSLog(@"story idiom for rotate is iPad");
return YES;
}
助けてください私はこれを修正してSplitViewControllerが正しくロードされるようにするか、デバッグするいくつかのテクニックを手伝ってくれます(例えば、どうすればSV CはrootViewControllerにありますが、回転の面倒をデバッグする他の方法はありますか?)