背景&目的:私はUISplitViewControllerベースのiPadアプリを持っています - これまでは4方向をサポートしていましたが、今はランドスケープのみにロックしたいと思います。 左ビューコントローラのshouldAutorotateToInterfaceOrientation
を変更して横向きモードのみをサポートしましたが、これによりviewWillAppear
が呼び出されなくなりました。ViewWillAppearはUISplitViewControllerで呼び出されません
詳細:私のiPadのビューコントローラは以下のように編成されています。両方DetailViewController.m
とHostManagerViewController.m
は
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
HostManagerViewController *hvc = [[[HostManagerViewController alloc]
initWithNibName:nil bundle:nil] autorelease];
self.detailViewController = [[[DetailViewController alloc]
initWithNibName:nil bundle:nil] autorelease];
UINavigationController *rootNav = [[[UINavigationController alloc]
initWithRootViewController:hvc] autorelease];
UISplitViewController *splitVC= [[[UISplitViewController alloc] init] autorelease];
[splitVC setViewControllers:[NSArray arrayWithObjects:rootNav,
detailViewController, nil]];
splitVC.delegate = detailViewController;
[window addSubview:splitVC.view];
[window setRootViewController:splitVC];
return YES;
}
viewWillAppear
が呼び出されます:
window
`-- splitVC (UISplitViewController)
`-- rootNav (UINavigationController)
`-- hvc (HostManagerViewController, derived from UIViewController)
`-- detailViewController (DetailViewController, derived from UIViewController)
これは以下のようにアプリケーションデリゲートで実装されています
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Console output:
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Hostmanager: Viewdidload
Should rotate called to hostmanager with 1
Hostmanager: viewwillappear
私は「を
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}
へのコード」HostManagerViewController
を変更したときしかしHostManagerViewControllerのviewWillAppear`が呼び出されていません。コンソール出力は
Should rotate called to hostmanager with 1 (1 is the numeric value of interfaceOrientation)
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Hostmanager: Viewdidload
Should rotate called to hostmanager with 1
のみランドスケープモードは、Info.plistの
EDITでサポートされています:挿入のNSLogメッセージは基本的にshouldAutorotateToInterfaceOrientation
、viewWillAppear
とViewDidLoad
このプロジェクトのサンプルをアップロードすることは可能ですか? – ACBurk
これを実行しているiOSバージョンは何ですか? – ACBurk
私は4.3を使用しています。それをより小さなテストケースに縮小することができます。どこにアップロードしますか? –