Contexte & Objectif: J'ai une application iPad basée sur UISplitViewController - jusqu'à présent, elle supportait 4 orientations mais maintenant je veux la verrouiller uniquement en mode paysage. J'ai changé shouldAutorotateToInterfaceOrientation
du contrôleur de vue gauche pour prendre en charge uniquement le mode paysage, mais cela empêche son viewWillAppear
d'être appelé.ViewWillAppear ne se fait pas appeler avec UISplitViewController
Détails: Mes contrôleurs de vue iPad sont organisés comme suit:
window
`-- splitVC (UISplitViewController)
`-- rootNav (UINavigationController)
`-- hvc (HostManagerViewController, derived from UIViewController)
`-- detailViewController (DetailViewController, derived from UIViewController)
Ceci est mis en œuvre dans le délégué App comme ci-dessous:
- (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
est appelée lorsque les deux DetailViewController.m
et HostManagerViewController.m
contiennent
- (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
Mais quand je change 'le code de la
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}
puis' HostManagerViewController
viewWillAppear` de HostManagerViewController n'est pas invoqué. Sortie de la console
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
Seuls les modes Paysage sont pris en charge dans le Info.plist
EDIT: messages Inséré NSLog pour suivre shouldAutorotateToInterfaceOrientation
, viewWillAppear
et ViewDidLoad
est-il possible pour vous de télécharger un échantillon de ce projet? – ACBurk
quelle version iOS utilisez-vous? – ACBurk
J'utilise 4.3. Le réduire à un plus petit testcase peut être fait. Où puis-je le télécharger ensuite? –